AmbitionBox
Discover Best Places to work in India
Discover best places to work
Compare & find best workplace
Bring your workplace to life
Highlight your company's perks
Read reviews for 6L+ companies
Rate your former or current company
Discover salaries for 8L+ companies
Calculate your take home salary
Check your market value
Help other jobseekers
Read interviews for 90K+ companies
Interviews questions for 1K+ colleges
Contribute your interview questions
Java Programming
Which all lines are part of the output when the following code is compiled and run. Select the one correct answer.
public class test { public static void main(String args[]) { for(int i = 0; i < 3; i++) { for(int j = 3; j <= 0; j--) { if(i == j) continue; System.out.println(i + " " + j); } } } }
1 1
2 3
3 0
The program does not print anything
What happens when the following class is compiled and run. Select one correct answer.
public class test { public static void main(String args[]) { int x = 0, y = 1, z; if(x) z = 0; else z = 1; if(y) z = 2; else z = 3; System.out.println(z); } }
The program prints 0
The program prints 1
The program prints 2
The program does not compile because of problems in the if statement.
What all gets printed when the following gets compiled and run. Select the two correct answers.
public class example { public static void main(String args[]) { int x = 0; if(x > 0) x = 1; switch(x) { case 1: System.out.println(1); case 0: System.out.println(0); case 2: System.out.println(2); break; case 3: System.out.println(3); default: System.out.println(4); break; } } }
0
1
2
3
What is the result of compiling and running the following program. Select one correct answer.
public class test { public static void main(String args[]) { int i = -1; i = i >> 1; System.out.println(i); } }
63
-1
127
Which of the following are correct. Select all correct answers.
Java provides two operators to do left shift - << and <<<
>> is the zero fill right shift operator
>>> is the signed right shift operator
For positive numbers, results of operators >> and >>> are same
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); } }
7
23
2147483646
public class test { public static void main(String args[]) { int x, y; x = 5 >> 2; y = x >>> 2; System.out.println(y); } }
5
80
64
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); } }
4
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); } }
Which operator is used to perform bitwise exclusive or
&
^
|
~
Join India’s largest community to research company culture
Are you a student or working professional?
Student/Never worked
I am a student/I have never worked
Working Professional
I am working/I have worked before
What are your preferred job locations?
Popular Cities
Other Cities
Follow your preferred designations/job profiles
Suggestions based on your job profile
vs
Similar Companies