1. Which of the following is not a Java keyword?
a) class
b) interface
c) extends
d) implement
2. Which method is the entry point of a Java program?
a) start()
b) main()
c) run()
d) init()
3. Which data type is used to store true/false values in Java?
a) bit
b) int
c) boolean
d) char
4. What is the default value of a local variable in Java?
a) 0
b) null
c) false
d) No default value (must be initialized)
5. Which keyword is used to inherit a class in Java?
a) this
b) super
c) extends
d) implements
6. Which of these is a valid declaration of a main method?
a) public void main(String[] args)
b) public static void main(String[] args)
c) private static void main(String args[])
d) static public void Main(String args[])
7. What is the size of an int variable in Java?
a) 8 bits
b) 16 bits
c) 32 bits
d) 64 bits
8. Which package contains the Scanner class?
a) java.util
b) java.io
c) java.lang
d) java.net
9. What is the output of System.out.println(5 + 2 + \”Java\”)?
a) 7Java
b) Java7
c) 5Java2
d) Error
10. Which of these is a wrapper class in Java?
a) int
b) Integer
c) number
d) wrapper
11. Which exception is thrown when a required file is not found?
a) IOException
b) FileNotFoundException
c) NullPointerException
d) ArrayIndexOutOfBoundsException
12. What is method overloading?
a) Using multiple classes with the same method
b) Changing method name and parameters
c) Defining multiple methods with the same name but different parameters
d) Extending more than one class
Sign in to your account