Online Exam Quiz

questionQuestion  1 to 30

What is the return type of the hashCode() method in Java?

  • int
  • long
  • String
  • float
Mark for review

Which of the following is used to find the absolute value of a number in Java?

  • Math.abs()
  • Math.absolute()
  • Math.absValue()
  • Math.absoluteValue()
Mark for review

Which of the following is not an access modifier in Java?

  • public
  • private
  • protected
  • internal
Mark for review

What is the output of the following code? System.out.println(2 + "3");

  • 5
  • 23
  • 2 3
  • Error
Mark for review

Which of the following is a wrapper class in Java?

  • int
  • float
  • char
  • Integer
Mark for review

Which of the following is used to handle exceptions in Java?

  • try-catch
  • if-else
  • switch-case
  • for-loop
Mark for review

Which of the following is used to generate random numbers?

  • Random class
  • Math.random()
  • java.util.Random
  • All of the above
Mark for review

What is the size of an int data type in Java?

  • 4 bytes
  • 2 bytes
  • 8 bytes
  • 1 byte
Mark for review

Which of the following is not a Java feature?

  • Object-Oriented
  • Portable
  • Dynamic
  • Use of Pointers
Mark for review

What is the superclass of all classes in Java?

  • Object
  • Class
  • Interface
  • Base
Mark for review

Which method is called when an object is created in Java?

  • create()
  • init()
  • constructor
  • new()
Mark for review

Which of the following is a reserved word in Java?

  • main
  • System
  • new
  • print
Mark for review

Which method is used to convert an object to a string representation?

  • toString()
  • getString()
  • convertString()
  • toChar()
Mark for review

Which keyword is used to define a subclass in Java?

  • subclass
  • inherits
  • extends
  • implements
Mark for review

Which of the following is true about Java's garbage collection?

  • It is manual
  • It is automatic
  • It is optional
  • None of the above
Mark for review

Which operator is used for comparing two values?

  • =
  • ==
  • !=
  • <>
Mark for review

Which method is used to stop a thread in Java?

  • stop()
  • end()
  • terminate()
  • kill()
Mark for review

Which method is used to add an element at the end of a list in Java?

  • addElement()
  • insert()
  • append()
  • add()
Mark for review

Which of the following is not a valid way to create an object in Java?

  • new ClassName()
  • Class.forName("ClassName").newInstance()
  • ClassName.clone()
  • ClassName.new()
Mark for review

Which of the following is a valid declaration of a float variable in Java?

  • float f = 1.0;
  • float f = 1.0d;
  • float f = 1;
  • float f = 1.0f;
Mark for review

Which method is used to read a line of text from the console in Java?

  • readLine()
  • read()
  • getLine()
  • nextLine()
Mark for review

Which method must be implemented by all threads in Java?

  • run()
  • start()
  • stop()
  • sleep()
Mark for review

What is the result of 10 % 3?

  • 0
  • 1
  • 2
  • 3
Mark for review

Which method is used to start a thread execution?

  • run()
  • start()
  • execute()
  • launch()
Mark for review

Which of the following is a marker interface?

  • Serializable
  • Cloneable
  • Remote
  • All of the above
Mark for review

What is the default value of a boolean variable in Java?

  • TRUE
  • FALSE
  • 0
  • null
Mark for review

What is the use of the 'this' keyword in Java?

  • To refer to the current object
  • To refer to a superclass object
  • To refer to a static object
  • To refer to a local variable
Mark for review

Which interface is used to store a collection of elements in Java?

  • List
  • Set
  • Map
  • All of the above
Mark for review

Which of the following is the correct way to handle multiple exceptions in Java 7 and later?

  • Multiple catch blocks
  • A single catch block
  • A single catch block with multiple exceptions separated by a comma (,)
  • )
Mark for review

Which of the following is not a primitive data type in Java?

  • int
  • float
  • boolean
  • String
Mark for review

blinkerOnline

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • Answered
  • Not Answered
  • Marked for Review