This is a Tutorial site for school and college students. Programs and technical analysis on BlueJ for ICSE and ISC Students, C programming, C++ programming and Data structure through C programming language are posted here. Engineering college students can get help on C and C++ languages from this site.
Tuesday, May 18, 2010
ICSE Board guess question, answer and sample programs on BlueJ (2)
Today we'll deal with icse computer applications sample papers.
Write any two rules for naming varible declaration.
Two rules of variable declaration are
(i) Variable name must start with an alphabet
(ii) Java keywords can't be used as variable name
Write down the difference between prefix and postfix operators.
Prefix and postfix operators while used in single statement has no difference. e.g
a++ or ++a has the same meaning,both are incremented by 1 after the statement is executed. But in expression they reacts differently.
e.g int a=10;
Here the output will be 10 as when postfix expression is used in expression, the expression executes first and then the operator works. So println() will display 10 and after that 'a' will be incremented by 1.
Again in prefix, the operator will work first and after that the expression will work.
Here the output will be 11.
A class is a user-defined data type. Say whether the statement is correct or not and justify your answer.
This statement is correct as we know that type defines the nature and behavior of it's instance. By defining a class we also defines the nature and behavior of it's instance which are known as object.So class can be called as user defined data type.
Give an example of conditional operator.
Suppose int a,b,max are three variables and a and b holds unique value. We want to assign the maximum value on the variable max.
Using conditional statement we can write the codings as below
Write a function to suppress negative elements of an array to bottom without altering the original sequence i.e. if array contains
5 , -4 , 3 , -2 , 6 , -11 , 12 , -8 , 9
Then the return array will be : 5 , 3 , 6, 12 , 9 , -4 , -2 , -11 , -8
int separate(int a,int n)
int pos=new int[n];
int neg=new int[n];
for(int j=0;j< n1;j++)
}What is inheritance and how is it useful in java ?
Inheritance is the process of acquiring properties, means data members and function members of any defined class in another class. Inheritance means reuse of codes. By the power of inheritance a class can acquire nature and behavior of a predefined class without writing a single line of code.
There are three types of inheritance - multilevel, multiple and hierarchical. Java supports multilevel and hierarchical inheritance.
What is an exception ? how does java deal with it ?
Exception means run time abnormality.
Java uses Exception Handler to deal with such situation. In java we can use throws clause, try....catch , try...finally block and throw clause as exception handler.
What is meant by polymorphism? Give an example.
Polymorphism is one of the four features of OOPs. When same operator or same function behaves differently in different environment, it is called polymorphism. There are three types polymorphism, operator overloading, function overloading and
function overriding. Constructor overloading is an example of function overloading.
State difference between call-by-value and call-by-reference.
When variables are used as actual and formal argument, it is called call by value and call by reference means when objects are used as actual and formal arguments.
What output will the following code fragment produce ?
int val=9, res , n =1000;
res = n + val > 1750 ? 400 : 200 ;
Output will be 200
What will be the result of following two expressions if I =10 initially ?
I ) ++ I <=10 II ) I++ <=10For the first statement the result will be false and for the second statement the result will be true.Given the following set of identifiers:
long longval ; char ch ; int intval ; float fl ; short sh ;
Identify the datatype of the following expressions:
a) ‘a’-3 b) intval*longval-ch c) fl+ longval/sh d) longval * 3
Ans: a) int
Write a java program to print largest even and largest odd number from a list of
numbers entered through keyboard. The list terminates as soon as one enter 0 (zero).