Java coding interview questions and answers for Freshers 1. Explain the super keyword in Java and its use in constructor chaining? Answer: super is used to call a superclass's constructor or access superclass members. It's commonly used in constructor chaining to call the superclass constructor from a subclass constructor. 2. What is the purpose of the synchronized keyword in Java, and how does it work? Answer: synchronized is used to create synchronized blocks or methods to provide thread-safety by allowing only one thread to access a synchronized block at a time. 3. What is the purpose of ‘this’ keyword in Java, and how is it used? Answer: The ‘this’ keyword refers to the current instance of a class and is often used to distinguish between instance variables and method parameters with the same name. 4. What are inner classes in Java , and why are they used? Answer: Inner classes are classes defined within another class. They are used for encapsulation, organization, a...
Comments
Post a Comment