scjp MCQ Questions and Answers

Practice Mode
Showing 10 of 52 questions
Q1
Read this piece of code carefully if("String".toString() == "String") System.out.println("Equal"); else System.out.println("Not Equal");
  • A 1. the code will compile an print "Equal".
  • B 2. the code will compile an print "Not Equal".
  • C 3. the code will cause a compiler error.
Answer: Option A
Q2
Read this piece of code carefully if("String".toString() == "String") System.out.println("Equal"); else System.out.println("Not Equal");
  • A 1. the code will compile an print "Equal".
  • B 2. the code will compile an print "Not Equal".
  • C 3. the code will cause a compiler error.
Answer: Option A
Q3
Read this piece of code carefully
  • A 1. the code will compile an print
  • B 2. the code will compile an print
  • C 3. the code will cause a compiler error.
Answer: Option A
Q4
Read the code below. Will be the result of attempting to compile and run the code below.
  • A 1. The code does not compile.
  • B 2. The code compiles cleanly and shows
  • C 3. The code compiles cleanly and shows
  • D 4. The code throws an Exception at Runtime.
Answer: Option C
Q5
Read the code below. Will be the result of attempting to compile and run the code below.
  • A 1. The code does not compile.
  • B 2. The code compiles cleanly and shows "StringBuffer Version".
  • C 3. The code compiles cleanly and shows "String Version"
  • D 4. The code throws an Exception at Runtime.
Answer: Option A
Q6
Read the following code below.
  • A 1. Necessarily be an abstract class.
  • B 2. Should have the method public abstract void someMethod();
  • C 3. Should have the method public void someMethod() which has to throw an exception which is a subclass of java.lang.Exception.
  • D 4. Should have the method public void someMethod() which need not throw an Exception.
Answer: Option D
Q7
An Interface can never be private or protected.
  • A TRUE
  • B FALSE
Answer: Option B
Q8
A Vector class in jdk 1.2
  • A is public
  • B is final
  • C implements java.util.List
  • D is serializable
Answer: Option
Q9
A String Class
  • A is final
  • B is public
  • C is serializable
  • D has a constructor which takes a StingBuffer Object as an Argument
Answer: Option
Q10
Answer the question
  • A Should have someMethod which must necessarily be public.
  • B Should have someMethod which could be "friendly" or public
  • C Should have someMethod which should not throw any checked exceptions.
  • D Should have someMethod which cannot be sychronized as sychronized is not in the signature of the interface defination
Answer: Option
Questions and Answers for Competitive Exams Various Entrance Test