Online Exam Quiz

questionQuestion  1 to 30

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 of the following is not a control statement in Java?

  • break
  • continue
  • exit
  • return
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 get the current date and time in Java?

  • currentTime()
  • getTime()
  • now()
  • LocalDateTime.now()
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 method is called when an object is created in Java?

  • create()
  • init()
  • constructor
  • new()
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

What is the result of 10 % 3?

  • 0
  • 1
  • 2
  • 3
Mark for review

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

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

What is the base class for all exceptions in Java?

  • Throwable
  • Exception
  • RuntimeException
  • Error
Mark for review

Which package contains the Random class?

  • java.util
  • java.lang
  • java.io
  • java.awt
Mark for review

Which of the following is a wrapper class in Java?

  • int
  • float
  • char
  • Integer
Mark for review

Which method must be implemented by all threads in Java?

  • run()
  • start()
  • stop()
  • sleep()
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 compare two strings in Java?

  • equals()
  • compareTo()
  • ==
  • equalsIgnoreCase()
Mark for review

What is the superclass of all classes in Java?

  • Object
  • Class
  • Interface
  • Base
Mark for review

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

  • public
  • private
  • protected
  • internal
Mark for review

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

  • TRUE
  • FALSE
  • 0
  • null
Mark for review

What does the acronym JVM stand for?

  • Java Virtual Machine
  • Java Variable Machine
  • Java Virtual Method
  • Java Visual Machine
Mark for review

Which of the following is not a keyword in Java?

  • strictfp
  • null
  • instanceof
  • native
Mark for review

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

  • int
  • long
  • String
  • float
Mark for review

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

  • int
  • float
  • boolean
  • String
Mark for review

What is the output of System.out.println(Math.min(3, 7));?

  • 3
  • 7
  • 0
  • Error
Mark for review

What is the output of System.out.println("Hello World".substring(6));?

  • Hello
  • World
  • Hello World
  • World Hello
Mark for review

Which keyword is used to define an interface in Java?

  • class
  • interface
  • implements
  • extends
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

Which of the following is not a valid Java identifier?

  • _myVariable
  • $myVariable
  • 123myVariable
  • myVariable123
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 operator is used for comparing two values?

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

Which of the following is not a Java feature?

  • Object-Oriented
  • Portable
  • Dynamic
  • Use of Pointers
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