Java - Java.lang Class Questions and Answers

Practice Mode
Showing 10 of 24 questions
Q11
Which method is used to compare two objects for equality?
  • A equals()
  • B compare()
  • C ==
  • D equal()
Answer: Option A
Explanation: equals() method checks object equality
Q12
What is the parent class of all exception classes?
  • A Throwable
  • B Exception
  • C Error
  • D Object
Answer: Option A
Explanation: Throwable is the superclass of all errors and exceptions
Q13
Which class is used for string manipulation?
  • A String
  • B StringBuffer
  • C StringBuilder
  • D All of the above
Answer: Option D
Explanation: String class provides various methods for string operations
Q14
What does the clone() method do?
  • A Creates object copy
  • B Deletes object
  • C Compares objects
  • D Converts to string
Answer: Option A
Explanation: clone() creates and returns a copy of the object
Q15
Which method returns the runtime class of an object?
  • A getClass()
  • B getRuntimeClass()
  • C getType()
  • D classOf()
Answer: Option A
Explanation: getClass() returns the Class object representing runtime class
Q16
What is the purpose of the wait() method?
  • A Makes thread wait
  • B Stops program
  • C Terminates thread
  • D Pauses execution
Answer: Option A
Explanation: wait() causes current thread to wait until another thread notifies
Q17
Which class contains the Math.abs() method?
  • A Math
  • B Integer
  • C Number
  • D Object
Answer: Option A
Explanation: Math class provides static methods for mathematical operations
Q18
What is the default value of a boolean instance variable?
  • A false
  • B true
  • C 0
  • D null
Answer: Option A
Explanation: boolean instance variables are initialized to false by default
Q19
Which method is used to get the length of a string?
  • A length()
  • B size()
  • C getLength()
  • D getSize()
Answer: Option A
Explanation: length() method returns the number of characters in string
Q20
What is the superclass of Number class?
  • A Object
  • B Number
  • C Integer
  • D Math
Answer: Option A
Explanation: Number extends Object class directly
Questions and Answers for Competitive Exams Various Entrance Test