1.
What will be the output of the
following code fragment ?
int m = 10;
int n = 20;
while(++m<--n)
System.out.println(m);
2.
Given the following function :
public int
something(int x)
{
x=x<0?-x:x;
return x;
}
What
is the function something() doing ?
3.
Which of the following are
overloading the method :
int sum(int
x, int y) ?
a) int sum(int x,int y,int z)
b) float sum(int x,int y)
c) int sum(float x,float y)
d) int sum(int a,int b)
e) float sum(int x,int y,float z)
4.
Consider the following
statements :
int x=10 ,
y=15;
x= (x<y)
?(y+x) : (y-x);
What will be
the value of x after executing these statements ?
5.
The following function
give is part of some class.
public int
give(int i,int j)
{
if(j>i)
{
i+=j;
j=i-j;
i-=j;
}
while(i>=j)
i-=j;
return i;
}
i) What will the function
give(12,5) return ?
ii) What will the function
give(4,14) return ?
iii) What is the function give doing ?
6.
What will be the values
of s & c after execution of the following code:
a) s=0;
c=0;
s=(s*s)
+ (++c+s);
b)
s=30;
c=20;
s=(s/10)
* (c++ *s);
7.
Briefly define the
following terms :
Tokens
, identifier , mixed mode arithmetic , local variable , Unicode
8.
Differentiate between a
character literal & a String literal.
9.
With an example ,
briefly explain the functioning of the conditional operator.
10.
Name the data types
available for handling real numbers & also specify their size.
11.
What will the following
code fragment display ?
String
s= “six :” + 3 + 3;
System.out.println(s);
12.
Consider the following
for statement :
for(int
x=1;;x++)
{
// body of loop
}
a)
What type of loop would
you call the above ?
b)
What statement would
you use to exit from such a loop ?
c)
Implement a similar
type of loop using the while statement.