Tuesday, 18 August 2009

Java Certification Question 0068

What will happen when you attempt to compile and run this code?

private class Base{}

public class Vis{

transient int iVal;

public static void main(String elephant[]){

}

}

1)Compile time error: Base cannot be private
2)Compile time error indicating that an integer cannot be transient
3)Compile time error transient not a data type
4)Compile time error malformed main method



Answer 1) Compile time error: Base cannot be private

A top level (non nested) class cannot be private.

No comments: