Showing posts with label ICSE Guess. Show all posts
Showing posts with label ICSE Guess. Show all posts

Friday, January 22, 2016

ICSE Computer Application Paper 2016 Guess Questions and Solutions


In this article students appearing in ICSE 2016 may get suggestions for Computer Application paper. Some of the answers are lengthy but it actually covers answer of two or more questions in one answer. Best of Luck!


     1.    What are the access specifiers used in Java

Ans: There are four access specifiers in java – public, private, protected and default. Members with public specifers can be accessed from any where, even from outside the package. Members with private specifers can be accessed from only within the class. Members with protected specifers can be accessed from sub classes only.

      2.    Differentiate between == and equals () method

Ans: == is a relational operator which is used to check equality of two primitive values. The same operator can be used on objects to check the equality of references, not value.
The equals () method is a String class method which is used to check whether the invoking String object and the argument String objects have same value or not. The method returns boolean value.

     3.    Differentiate between call by value and call by reference

Ans: Both are method calling techniques while call by value uses variable as arguments and call be reference uses objects as arguments.
Call by value can not modify actual argument values after the execution of function but call by reference can modify actual argument values.

    4.    What is actual parameter and formal parameter

Ans:  Actual arguments are the variables or objects used in function calling statement and formal arguments are the variables or objects declared in argument zone of a function definition.

    5.    Between binary and linear search, which one is better and why

Ans: Linear searching technique is better that binary search as this technique don’t have any preconditions like binary search. Linear search can be performed with the elements stored in as it is condition and this storing technique can be applied for unique value search as well as category wise search.
6.    What are the preconditions of binary search
For binary search, the elements should be in sorted order and the middle location value can be accessed directly.

     7.    What is instance variable and method

Instance members – both variable and method are those whose existence comes after creating the object and can be used after creating object. For each objects of a class, separate copies of instance variables are created while only one copy of function will be created for any number of objects.

Download eBook on BlueJ 

    8.    What is constructor and how it differs from a normal function

Constructor is a special function whose execution is must for creating object.

   Comparison between constructor and normal function

Constructor
Function
Constructor name must be the same as the class name.
Function name should not match with the class name.
Constructor has no return type, not even void.
Function must have a return type.
If constructor is not defined in a class, compiler supplies default constructor.
There is no such concept of default function

9.    What is default constructor
Default constructor is that constructor which is supplied by compiler during creation of an object if there is no constructor defined in a class. Default constructor is always empty body withour argument constructor.
Example of default constructor:
Suppose a class named MyClass is defined, Default constructor of MyClass looks like:
MyClass ()
{
}

    10. What is difference between default constructor and normal constructor

Default constructor is supplied by compiler while normal constructors are defined by programmers.

     11. What is exception handling

Exception is run time error and java uses some techniques to handle the run time abnormality. These techniques are known as exception handling.

     12. What are different techniques of exception handling

There are four techniques of exception handling in java and these are throws, try catch, throw and try finally.

    13. Comparison among three loops

For loop
While loop
Do while loop
Entry control loop
Entry control loop
Exit control loop
Control statement contains three statements, initialisation, conditional statement and reinitialisation of loop control variable
Control statement contains only conditional statement while initialisation of loop control variable is done above the loop and reinitialisation of loop control variable is done within the loop body, normally at the end.
Control statement contains only conditional statement while initialisation of loop control variable is done above the loop body or within the loop body during first iteration of the loop and in such case the same statement performs reinitialisation during other iteration excepting the first one.
Loop control variable is reinitialised by programmer
Loop control variable is normally reinitialised by user
Loop control variable is normally reinitialised by user
Loop may not execute even once if the condition is false
Loop may not execute even once if the condition is false
Loop will execute atleast once if the condition is false

    14. Different type of decision making statements

In java there are different decision making statements and they are – if, if  else, else if ladder, switch statement and conditional statement.

    15. Comparison between else if ladder and switch

Else if ladder
switch
else if ladder can work on all type of values even on objects.
switch can work only on int and char calues
Logical operators can be used in else if ladder
Logical operators can not be used in switch
Fall through situation does not arise in else if ladder
If break statement is not used at the end of case body, fall through situation occurs.
else is optional in else if
default is optional in switch




    16. What is Wrapper class

Wrapper classes are predefined class stored in java.lang package. Each primitive type has an equivalent Wrapper class. Wrapper classes are used to convert a primitive type value into it’s equivalent object. Some of the Wrapper classes are Integer, Double, Boolean etc.

     17. What are the OOPs principles


There are three OOPs principles – Encapsulation, Inheritance and Polymorphism.


      18.    What is infinite loop

In loop conditional statement is used to terminate the execution of the loop after certain time but if we set the condition to be true then it becomes infinite loop. In infinite loop, break statement is necessary to send the control out of loop body. Example of infinite loops:

for (::)
{
 Statements
If(condition)
break;
}
while (true)
{
 Statements
If(condition)
break;
}
do
{
 Statements
If(condition)
break;
}while(true);

     19.    Two types of Java programs


Java applet and stand alone application.

Saturday, November 8, 2014

ICSE 2015 Computer Paper Suggestion from the Board



Program No 1:


Input any word in lower case and display its output in uppercase.



Program using the main function


import java.io.*;
class CaseChange
{
    String s1,s2="";
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    public void takeString() throws Exception
    {
       System.out.print("\nEnter the word:");
      s1=br.readLine();
      
      for(int i=0;i< s1.length();i++)
      {
           if(Character.isUpperCase(s1.charAt(i)))
           s2=s2+Character.toLowerCase(s1.charAt(i));
           else
           s2=s2+s1.charAt(i);
        }
             System.out.println(s2);
        }
      
    public static void main(String args[])throws Exception
    {
         CaseChange ob=new CaseChange();
         ob.takeString();
        }
    }
        
   

  Program exclusively for BlueJ Editor


class CaseChange
{
   
    public void takeString(String s1)
    {
       String s2="";
      
      for(int i=0;i< s1.length();i++)
      {
           if(Character.isUpperCase(s1.charAt(i)))
           s2=s2+Character.toLowerCase(s1.charAt(i));
           else
           s2=s2+s1.charAt(i);
        }
             System.out.println(s2);
        }
       
       }
        

Program No 2:


Total number of alphabets present in the word 


. For example, if



Lower case : snowy

Upper case: SNOWY

Total number of alphabets : 5.


Program using main function



import java.io.*;
class CountLetters
{
    String s1;
    int i,len,count=0;
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   
    public void takeString() throws Exception
    {
       System.out.println("Enter the string:");
       s1=br.readLine();
       len=s1.length();
      for(int i=0;i< len;i++)
      {
           if(Character.isLetter(s1.charAt(i)))
           count++;
        }
             System.out.println("No of alphabets:"+count);
        }
       public static void main(String args[])throws Exception
       {
            CountLetters ob=new CountLetters();
            ob.takeString();
        }
       }
        
   

 Program exclusively for BlueJ Editor


lass CountLetters
{
    
    public void takeString(String s1)
    {
       int count=0;
       int len=s1.length();
      for(int i=0;i< len;i++)
      {
           if(Character.isLetter(s1.charAt(i)))
           count++;
        }
             System.out.println("No of alphabets:"+count);
        }
        }
        

Program No 3



Write a program to store elements in an array of size 4 4 and perform the following. Find the sum of:

(a)                each row and display

(b)               each column and display

(c)
all the elements of the array.
[15]

import java.io.*;
class Matrix
{
    int arr[][]=new int[4][4];
    int i,j,sum;
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    public void takeValues() throws Exception
    {
       for(i=0;i< 4;i++)
       {
            for(j=0;j< 4;j++)
            {
                 System.out.print("\nValue:");
                 arr[i][j]=Integer.parseInt(br.readLine());
                }
            }
        }
         public void showResult()
         {
              System.out.println("\nElements in the array:\n");
             for(i=0;i< 4;i++)
             {
             for(j=0;j< 4;j++)
            {
                 System.out.print(" "+arr[i][j]);
             }
             System.out.println();
            }
           
            System.out.println("\nRow wise sum of the elements:\n");
             for(i=0;i< 4;i++)
             {
                 sum=0;
             for(j=0;j< 4;j++)
            {
                 sum+=arr[i][j];
             }
             System.out.println("Row Number:"+ (i+1)+"="+sum);
             sum=0;
            }
          System.out.println("\nColumn wise sum of the elements:\n");
             for(i=0;i< 4;i++)
             {
                 sum=0;
             for(j=0;j< 4;j++)
            {
                 sum+=arr[j][i];
             }
             System.out.println("Row Number:"+ (i+1)+"="+sum);
             sum=0;
            }
        }
            public static void main(String args[])throws Exception
            {
                 Matrix ob=new Matrix();
                 ob.takeValues();
                 ob.showResult();
           
        }
    }
   
   

    Sample Input Output

   
   
Value:6

Value:1

Value:2

Value:3

Value:4

Value:33

Value:4

Value:5

Value:6

Value:5

Value:6

Value:6

Value:5

Elements in the array:

 3 4 5 6
 1 2 3 4
 33 4 5 6
 5 6 6 5

Row wise sum of the elements:

Row Number:1=18
Row Number:2=10
Row Number:3=48
Row Number:4=22

Column wise sum of the elements:

Row Number:1=42
Row Number:2=16
Row Number:3=19
Row Number:4=21


Progran No 4




Read N numbers in a single dimensional array and
calculate  the  highest  and  the  least  number  along  with  their  corresponding
positions.                           
For example,     if            
                INPUT : 8, 4, 5, 1, 7          
                OUTPUT,            
                Highest : 8           Position : 1
                Lowest :  1          Position : 4




import java.io.*;
class Array1
{
    int arr[];
    int i,min,max,minp,maxp,n;
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    public void takeValues() throws Exception
    {
      
        System.out.print("\nHow many elements to store:");
        n=Integer.parseInt(br.readLine());
        arr=new int[n];
        System.out.println("\nEntering Values:");
        for(i=0;i< n;i++)
       {
                System.out.print("\nValue:");
                 arr[i]=Integer.parseInt(br.readLine());
        }
    }
           public void showResult()
         {
             max=arr[0];
            min=arr[0];
            minp=0;
            maxp=0;
           
             for(i=1;i< n;i++)
             {
             if(arr[i]>max)
             {
                  max=arr[i];
                  maxp=i+1;
                }
                else if(arr[i]< min)
                {
                     min=arr[i];
                     minp=i+1;
                    }
                }
                System.out.println("Entered Values:");
                for(i=0;i< n;i++)
                System.out.print(" "+arr[i]);
               
                System.out.println("Maximum Value= "+max);
               System.out.println("Maximum Value position= "+maxp);
               System.out.println("Minimum Value= "+min);
               System.out.println("Minimum Value position= "+minp);

             }
            
       
            public static void main(String args[])throws Exception
            {
                 Array1  ob=new Array1 ();
                 ob.takeValues();
                 ob.showResult();
           
        }
    }
   

    Sample Input and Output

   

How many elements to store:12

Entering Values:

Value:44

Value:5

Value:66

Value:5

Value:4

Value:555

Value:4

Value:4

Value:3

Value:33

Value:23

Value:4
Entered Values:
 44 5 66 5 4 555 4 4 3 33 23 4
Maximum Value= 555
Maximum Value position= 6
Minimum Value= 3

Minimum Value position= 9

[15]

Subscribe via email

Enter your email address:

Delivered by FeedBurner