Java Programming Questions and Answers
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;
}
}
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[]) {
i[0] = 2;
i[0] *= 2;
}
}
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);
}
}
Which of these are valid declarations for the main method?
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 initial value of an instance variable of type String that is not explicitly initialized in the program is --. Select the one correct answer
The initial value of an local variable of type String that is not explicitly initialized in the program is --. Select the one correct answer
What is the minimum value of char type. Select the one correct answer.
How many bytes are used to represent the primitive data type int in Java.
What is the legal range of values for a variable declared as a byte