Java MCQ – Home
Java Basic MCQ
➤ Java Hello World MCQ
➤ Find Java Keywords
➤ Java Identifier Quiz
➤ Java Data Types Quiz
➤ If-Else MCQ in Java-1
➤ If-Else MCQ in Java-2
Object class MCQ
➤ Object Class Quiz
➤ equals() Method Quiz
➤ Hashcode Value Quiz
➤ toString() Method Quiz
➤ Clone() Method Quiz
Multithreading MCQ
➤ Define a Thread-1
➤ Define a Thread-2
➤ Get/set ThreadName
➤ Thread State MCQ
➤ Thread Priority MCQ
➤ Yield(), join() & sleep()
➤ Synchronization MCQ
➤ Interthread Comms
➤ Deadlock, Daemon
Exception Handling
➤ Exception Handling-1
➤ Exception Handling-2
➤ Exception Handling-3
➤ Java try-catch MCQ-1
➤ Java try-catch MCQ-2
➤ Java try-catch MCQ-3
➤ Nested try-catch MCQ
➤ throw Keyword MCQ
➤ finally Block MCQ-1
➤ finally Block MCQ-2
➤ throws Keyword MCQ
Generics MCQ
➤ Java Generics Quiz-1
➤ Java Generics Quiz-2
➤ Java Generics Quiz-3
Collection Framework
➤ Collections Quiz-1
➤ Collections Quiz-2
➤ ArrayList MCQ-1
➤ ArrayList MCQ-2
➤ LinkedList MCQ
➤ Vector Stack MCQ
➤ Java Cursors MCQ
➤ Java TreeSet MCQ
➤ TreeSet & Comparator
Q1) Which is a valid keyword in Java?
a) new
b) delete
c) both
d) None of these
View Answer
Answer:- a) newIn Java, we have a “new” keyword to create objects but the “delete” keyword is not there. Because the destruction of the object is the responsibility of garbage collectors, not of programmers.
Q2) Which is an invalid keyword in Java?
a) byte
b) Short
c) int
d) long
View Answer
Answer:- b) ShortJava keywords doesn’t contain any uppercase letters. “Short” is the name of a class, and “short” is a data type.
Q3) Find Invalid Java keyword?
a) break
b) continue
c) return
d) exit
View Answer
Answer:- d) exitJava have exit() method, not a keyword.
Q4) Find an invalid Java keyword?
a) instanceof
b) sizeof
c) strictfp
d) None of these
View Answer
Answer:- b) sizeofJava doesn’t contain “sizeof” keyword.
Q5) Find all invalid Java keywords? (More than one options are correct).
a) throw
b) throws
c) thrown
d) through
View Answer
Answer:- c) thrown and d) through are invalid Java keywords.Q6) Which of the following are invalid Java Keywords?
a) final
b) finally
c) finalize
d) None of these
View Answer
Answer:- c) finalizefinalize() is a method defined in java.lang.Object class.
Q7) Which is a valid keyword in Java MCQ?
1) extend
2) implement
3) imports
4) synchronize
5) None of these
View Answer
Answer:- 5) None of these.Observe keywords once again. The “synchronized” is a keyword, not “synchronize”. “extends” is a keyword, not “extend”. “implements” is a keyword, not “implement”. “import” is a keyword, not “imports”. “instanceof” is a keyword, not “instanceOf”. “const” is a keyword, not “constant”.
Q8) Which of the following is not a Java reserved word?
a) public
b) static
c) void
d) main
View Answer
Answer:- d) main“main” is an identifier having special functionality, but it is not a reserved word.
Q9) Find the valid Java keywords?
a) null
b) true
c) false
d) None of these
View Answer
Answer:- d) None of theseThe null, true, and false are reserved literals, not a keywords. They can’t be used as an identifiers.
Q10) Which of the following keyword is not a data type in Java?
a) int
b) void
c) float
d) boolean
View Answer
Answer:- b) voidThe void keyword is a return type, not a data type.
Q11) Which of the following is a reserved keyword in Java?
a) object
b) strictfp
c) main
d) system
View Answer
Answer:- b) strictfpThe strictfp keyword is a modifier that restricts the floating-point calculations to assure portability and it was added in Java version 1.2.
Q12) In Java which of the following are unused keywords?
a) const
b) goto
c) Both (a) & (b)
d) None of these
View Answer
Answer:- c) Both (a) & (b)Java contains two unused keywords “const” and “goto”.
Q13) Find out valid Java keywords?
- main
- String
- static
- synchronize
- sizeof
- finalize
- strictf
- Void
- instanceOf
- object
- Public
- imported
- final
- package
- enumeration
- do_while
- true
- array
- null
- Class
- protect
- implement
- that
- thrown
- constant
- requires
- require
- open
- uses
- to
View Answer
Answer:- Among these options, only 3 are valid Java keywords. They are:- 3.static, 13.final, and 14.packageNote:- Keyword contains only lowercase letters.
If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or do you find anything incorrect? Let us know in the comments. Thank you!
null is a keyword
in Q13 answer not mention null
In Java, null is not technically a keyword, but it is a reserved word used as a literal. It’s similar to true and false, which are also literals.