Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Predict the Answer/Output

SET: 1

o.1. What will the following function return when executed?


i) double p= Math.rint (17.6);
(i) float k= Math.ceil(-7.8);
0.2. What will be the output of p = 15.3/3, if p is:
(i) float
(ii) int

Q.3. Predict the output:


(i) System.out.println("Answer="+Math.sqrt(Math.ceil(8.79));
(ii) "DELHI".compare'To("Delhi");
Q.4. What will be the output?
String a= "10", b= "25",c;
c=a+b;
System.out.println( "The value of c ="+c);
int sum= Integer.parselnt(a) + Integer.parselnt (b);
System.out.println( "The value of sum ="+sum);

Q.5. What will be the output of the following statement?


(i) int a=10;
a* ++a;
System.out.println( "The value of a ="+a);
(i) int a=25, b=25,c;
C=b-- * ++a;

System.out.println( "The value of c ="+c);


Q.6. What will be the output of the program?
class Test

public static void main(String l args)

int x=20;
String sup =
(x < 15)? "small" : (x < 22)? "tiny": "huge";
System.out.println(sup);

Q.7. What will be the output of the program?


class Test

public static void main(String l| args)

int x= 0;
int y= 0;
for (int z = 0; z < 5; zt4)

if(( ++x> 2)& (++y > 2)


X++;

System.out.println(x +" y
Q.8. What will be the
class Bitwise output of the
program?
public static void
main(String [l args)
int x 11 & 9;
=

inty = x^ 3;
System.out.println( y | 12 );
Q.9. What will be the of the
class Test output program?
static int s;
public static void
main(String [l args)
Test p =
new Test();
p.start();
System.out.println(s);
void start0

int x = 7;

twice(x);
System.out.print(x +" ");

void twice(int x)

X = x*2;
S = X;

Q.10. What will be the output of the program?


public class Test

public static void leftshift(int i, int j)

i se j

public static void main(String args[])

int i = 4, j = 2;
leftshift(, j);

You might also like