scjp MCQ Question and Answer
scjp MCQ Question and Answer
1. Read this piece of code carefully
if("String".toString() == "String")
System.out.println("Equal");
else
System.out.println("Not Equal");
- 1. the code will compile an print "Equal".
- 2. the code will compile an print "Not Equal".
- 3. the code will cause a compiler error.
2. Read this piece of code carefully
if("String".toString() == "String")
System.out.println("Equal");
else
System.out.println("Not Equal");
- 1. the code will compile an print "Equal".
- 2. the code will compile an print "Not Equal".
- 3. the code will cause a compiler error.
3. Read this piece of code carefully
- 1. the code will compile an print
- 2. the code will compile an print
- 3. the code will cause a compiler error.
4. Read the code below. Will be the result of attempting to compile and run the code below.
- 1. The code does not compile.
- 2. The code compiles cleanly and shows
- 3. The code compiles cleanly and shows
- 4. The code throws an Exception at Runtime.
5. Read the code below. Will be the result of attempting to compile and run the code below.
- 1. The code does not compile.
- 2. The code compiles cleanly and shows "StringBuffer Version".
- 3. The code compiles cleanly and shows "String Version"
- 4. The code throws an Exception at Runtime.
6. Read the following code below.
- 1. Necessarily be an abstract class.
- 2. Should have the method public abstract void someMethod();
- 3. Should have the method public void someMethod() which has to throw an exception which is a subclass of java.lang.Exception.
- 4. Should have the method public void someMethod() which need not throw an Exception.
8. A Vector class in jdk 1.2
- is public
- is final
- implements java.util.List
- is serializable
9. A String Class
- is final
- is public
- is serializable
- has a constructor which takes a StingBuffer Object as an Argument
10. Answer the question
- Should have someMethod which must necessarily be public.
- Should have someMethod which could be "friendly" or public
- Should have someMethod which should not throw any checked exceptions.
- Should have someMethod which cannot be sychronized as sychronized is not in the signature of the interface defination