Basic Java Interview Question and Answers

21. What are wrapper classes?
  Wrapper classes are classes that allow primitive types to be accessed as objects.
 
Your Name Your Email-ID
Your Answer
22. What is the difference between overloading and overriding?
 
  • In overloading, there is a relationship between methods available in the same class whereas in overriding, there is relationship between a superclass method and subclass method.
  • Overloading does not block inheritance from the superclass whereas overriding blocks inheritance from the superclass.
  • In overloading, separate methods are same name whereas in overriding, subclass method replaces the superclass.
 
Your Name Your Email-ID
Your Answer
23. Immutable objects are automatically thread-safe?
  True. Since the state of the immutable objects cannot be changed once they are created they are automatically synchronized/thread-safe.
 
Your Name Your Email-ID
Your Answer
24. Does Java provide any construct to find out the size of an object?
  No there is not sizeof operator in Java. So there is not direct way to determine the size of an object directly in Java.
 
Your Name Your Email-ID
Your Answer