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
What happens when the following program is compiled and run. Select the one correct answer.
public class example { int i[] = {0}; public static void main(String args[]) { int i[] = {1}; change_i(i); System.out.println(i[0]); } public static void change_i(int i[]) { int j[] = {2}; i = j; } }
The program does not compile.
prints 0
prints 1
prints 2
public class example { int i[] = {0}; public static void main(String args[]) { int i[] = {1}; change_i(i); System.out.println(i[0]); } public static void change_i(int i[]) { i[0] = 2; i[0] *= 2; } }
prints 4
prints 3
What happens when the following program is compiled and executed with the command - java test. Select the one correct answer.
class test { public static void main(String args[]) { if(args.length > 0) System.out.println(args.length); } }
The program compiles and runs but does not print anything.
the program compiles and runs and prints 0
the program compiles and runs and prints 1
the program compiles and runs and prints 2
Which of these are valid declarations for the main method?
public void main();
public static void main(String args[]);
public static void main(String );
public static int main(String args[]);
What would be the results of compiling and running the following class. Select the one correct answer.
class test { public static void main() { System.out.println("test"); } }
The program does not compile as there is no main method defined.
The program compiles and runs generating an output of "test"
The program compiles and runs but does not generate any output.
The program compiles but does not run.
The initial value of an instance variable of type String that is not explicitly initialized in the program is --. Select the one correct answer
null
""
NULL
0
The initial value of an local variable of type String that is not explicitly initialized in the program is --. Select the one correct answer
The local variable must be explicitly assigned
What is the minimum value of char type. Select the one correct answer.
-215
-215 - 1
-216 - 1
How many bytes are used to represent the primitive data type int in Java.
2
4
8
1
What is the legal range of values for a variable declared as a byte
0 to 256
-128 to 127
-127 to 128
-215 to 215 - 1
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