Java Quiz 1
Java Quiz 1
Question 1.
Read this piece of code carefully
if("String".toString() == "String")
System.out.println("Equal");
else
System.out.println("Not Equal");
Answers
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.
Question 2.
Read this piece of code carefully
if("String".trim() == "String")
System.out.println("Equal");
else
System.out.println("Not Equal");
Answers
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
Question 3.
Read the code below. Will be the result of attempting to compile and run the code below.
Question 4.
Read the code below. Will be the result of attempting to compile and run the code below.
Answers
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.
Question 5.
Read the following code below.
Question 6.
An Interface can never be private or protected.
Answers
True
False
Question 7.
A Vector class in jdk 1.2
1. is public
2. is final
3. implements java.util.List
4. is serializable
5. has only One constructor
Question 8.
A String Class
1. is final
2. is public
3. is serializable
4. has a constructor which takes a StingBuffer Object as an Argument
Question 9.
Question 10.
Answers