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.
Show Answer
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.
Show Answer
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.
Show Answer
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.
Show Answer
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.
Show Answer
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.
Show Answer
7. An Interface can never be private or protected.
  • TRUE
  • FALSE
Show Answer
8. A Vector class in jdk 1.2
  • is public
  • is final
  • implements java.util.List
  • is serializable
Show Answer
9. A String Class
  • is final
  • is public
  • is serializable
  • has a constructor which takes a StingBuffer Object as an Argument
Show Answer
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
Show Answer
Questions and Answers for Competitive Exams Various Entrance Test