hi,
What is the output of the following code?
public class TestLocal {
public static void main(
String args[]) {
String s[] = new String[6];
System.out.print(s[6]);
}
}
A) A null is printed
B) Compile time error
C) Exception is thrown
D) null followed by 0 is printed on the screen
answer is D.
What is the result of the following code?
public class MyTest {
int x = 30;
public static void main(String args[]) {
int x = 20;
MyTest ta = new MyTest();
ta.Method(x);
System.out.println("The x value is " + x);
}
void Method(int y){
int x = y * y;
}
}
A) The x value is 20.
B) The x value is 30.
C) The x value is 400.
D) The x value is 600.
answer is A.