Submitted by c-admin on Tue, 05/28/2019 - 01:16
What will the following program print?
public class InitTest{
public InitTest(){
s1 = sM1("1");
}
static String s1 = sM1("a");
String s3 = sM1("2");{
s1 = sM1("3");
}
static{
s1 = sM1("b");
}
static String s2 = sM1("c");
String s4 = sM1("4");
public static void main(String args[]){
InitTest it = new InitTest();
}
private static String sM1(String s){
System.out.println(s); return s;
}
}
Select 1 option
A. The program will not compile.
B. It will print : a b c 2 3 4 1
C. It will print : 2 3 4 1 a b c
D. It will print : 1 a 2 3 b c 4
E. It will print : 1 a b c 2 3 4
Submitted by c-admin on Tue, 05/28/2019 - 01:12
Which of the following are valid declarations?
Select 1 option
A. abstract int absMethod(int param) throws Exception;
B. abstract native int absMethod(int param) throws Exception;
C. float native getVariance() throws Exception;
D. abstract private int absMethod(int param) throws Exception;
E. strictfp float f;
Submitted by c-admin on Tue, 05/28/2019 - 01:03
What will the following program print when run?
public class ChangeTest {
private int myValue = 0;
public void showOne(int myValue){
myValue = myValue;
}
public void showTwo(int myValue){
this.myValue = myValue;
}
public static void main(String[] args) {
ChangeTest ct = new ChangeTest();
ct.showOne(100);
System.out.println(ct.myValue);
ct.showTwo(200);
System.out.println(ct.myValue);
}
}
Select 1 option
A. 0 followed by 100.
B. 100 followed by 100.
C. 0 followed by 200.
D. 100 followed by 200.
Submitted by c-admin on Tue, 05/28/2019 - 00:57
How can you declare a method someMethod() such that an instance of the class is not needed to access it and all the members of the same package have access to it?
Select 3 options
A. public static void someMethod()
B. static void someMethod()
C. protected static void someMethod()
D. void someMethod()
E. protected void someMethod()
F. public abstract static void someMethod()
Submitted by c-admin on Tue, 05/28/2019 - 00:55
What will the following program print when run?
public class ChangeTest {
private int myValue = 0;
public void showOne(int myValue){
myValue = myValue;
}
public void showTwo(int myValue){
this.myValue = myValue;
}
public static void main(String[] args) {
ChangeTest ct = new ChangeTest();
ct.showTwo(200);
System.out.println(ct.myValue);
ct.showOne(100);
System.out.println(ct.myValue);
}
}
Select 1 option
A. 0 followed by 100.
B. 100 followed by 100.
C. 0 followed by 200.
D. 100 followed by 200.
E. 200 followed by 200.
F. 200 followed by 100
Pages