AmbitionBox

Discover Best Places to work in India

Java Programming

Java Programming Questions and Answers

Showing 31 - 40 of 150 questions

31

What gets displayed on the screen when the following program is compiled and run. Select the one correct answer.


public class test {
	public static void main(String args[]) {
		int x;

		x = -3 >> 1;
		x = x >>> 2;
		x = x << 1;
 		System.out.println(x);
	}
}

 

 

a

1

b

7

c

23

d

2147483646

correct answer d
32

What gets displayed on the screen when the following program is compiled and run. Select the one correct answer.


public class test {
	public static void main(String args[]) {
		int x, y;

		x = 5 >> 2;
		y = x >>> 2;
 		System.out.println(y);
	}
}

 

 

a

5

b

80

c

0

d

64

correct answer c
33

What gets displayed on the screen when the following program is compiled and run. Select the one correct answer.


public class test {
	public static void main(String args[]) {
		boolean x = false;
		int a;
		if(x) a = x ? 1: 2;
		else a = x ? 3: 4;
		System.out.println(a);
	}
}

 

 

a

1

b

2

c

3

d

4

correct answer d
34

What gets displayed on the screen when the following program is compiled and run. Select the one correct answer.


public class test {
	public static void main(String args[]) {
		boolean x = true;
		int a;
		if(x) a = x ? 1: 2;
		else a = x ? 3: 4;
		System.out.println(a);
	}
}

 

 

a

1

b

2

c

3

d

4

correct answer a
35

Which operator is used to perform bitwise exclusive or

 

a

&

b

^

c

|

d

~

correct answer a,b
36

What gets displayed on the screen when the following program is compiled and run. Select the one correct answer.


public class test {
	public static void main(String args[]) {
		int x,y;
		x = 1 & 7;
		y = 3 ^ 6;
		System.out.println(x + " " + y);
	}
}

 

 

a

1 3

b

1 5

c

1 7

d

3 5

correct answer a,b
37

What gets displayed on the screen when the following program is compiled and run. Select the one correct answer.


public class test {
	public static void main(String args[]) {
		int x,y;
		x = 3 & 5;
		y = 3 | 5;
		System.out.println(x + " " + y);
	}
}

 

 

a

1 3

b

1 5

c

1 7

d

3 5

correct answer a,c
38

What gets printed when the following program is compiled and run. Select the one correct answer.



public class test {
	public static void main(String args[]) {
		byte x = 3;
		x = (byte)~x;
		System.out.println(x);
	}
}

 

 

a

3

b

0

c

1

d

-4

correct answer d
39

Which operator is used to perform bitwise inversion in Java. Select the one correct answer

a

~

b

!

c

|

d

^

correct answer a
40

What gets printed on the standard output when the class below is compiled and executed. Select the one correct answer.


public class ShortCkt {
	public static void main(String args[]) {
		int i = 0;
		boolean t = true;
		boolean f = false, b;
		b = (t | ((i++) == 0));
		b = (f | ((i+=2) > 0));
		System.out.println(i);		
	}
}

 

a

0

b

1

c

2

d

3

correct answer d
Select a company to compare with

vs

Similar Companies