Submitted by heartin on Sun, 09/13/2015 - 08:51
Consider the following code:
class Super { static String ID = "SUPER"; }
class Sub extends Super{
static { System.out.print("In Sub"); }
}
public class Test{
public static void main(String[] args){
System.out.println(Sub.ID);
}
}
What will be the output when class Test is run?
Select 1 option
A. It will print In Sub and SUPER.
B. It will print SUPER.
C. Depends on the implementation of JVM.
D. It will not even compile.
E. None of the above.
Submitted by heartin on Wed, 08/19/2015 - 03:31
Given:
abstract class Abstract1 {
public abstract static void main(String[] args);
}
abstract class Concrete1 extends Abstract1{
public static void main(String[] args) {
System.out.println("I am an abstrsct class");
}
}
What will be the result is we compile and run Concrete1?
Select 1 option:
A. Class Abstract1 will not compile
B. Classes will compile, but will fail at runtime as Concrete1 is an abstract class
C. Class will compile, run and print "I am an abstract class"
D. Class will compile, run and print nothing
Submitted by jjadmin on Tue, 08/18/2015 - 12:43
Given:
abstract class Abstract1 {
public static void main(String[] args) {
System.out.println("I am an abstrsct class");
}
}
abstract class Concrete1 extends Abstract1{
}
What will be the result is we compile and run Concrete1?
Select 1 option:
A. Class Abstract1 will not compile as abstract classes cannot have main method
B. Classes will compile, but will fail at runtime as Concrete1 does not have a main method
C. Class will compile, run and print "I am an abstract class"
D. Class will compile, run and print nothing
Submitted by jjadmin on Tue, 08/18/2015 - 08:24
Given:
public abstract class Abstract1 {
public static void main(String[] args) {
System.out.println("I am an abstract class");
}
}
Select 1 option:
A. Class will not compile as abstract classes cannot have main method
B. Class will compile, but will not execute as we cannot execute an abstract class main method
C. Class will compile, run and print "I am an abstract class"
D. Class will compile, run and print nothing