Java Quiz Lesson 3
Java Quiz Lesson 3
A) startThread()
B) run()
C) execute()
D) start()
Answer: D) start()
str.concat(" World");
System.out.println(str);
A) Hello World
B) World
C) Hello
D) Compilation error
Answer: C) Hello
Explanation: Strings in Java are immutable, meaning that the concat()
method does not modify the original string but returns a new string. Since
the result of concat() is not assigned to the str variable, the original string
"Hello" is printed.
A) FileReader
B) BufferedReader
C) FileInputStream
D) PrintWriter
Answer: A) FileReader
B) Declaring all fields as private and providing setter methods for them.
A) true
B) false
C) null
D) 0
Answer: B) false
System.out.println(arr[3]);
A) 0
B) 1
C) ArrayIndexOutOfBoundsException
D) Compilation error
Answer: C) ArrayIndexOutOfBoundsException
10. Which of the following collection classes in Java maintains the order of
elements?
A) HashSet
B) HashMap
C) TreeSet
D) LinkedList
Answer: D) LinkedList