Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Java Support Interview Questions and Answers

Ques 6. What is the 'this' keyword in Java?

'this' refers to the current instance of the class. It is used to differentiate instance variables from local variables when they have the same name. 'this' is also used to invoke current class methods and constructors.

Example:

Example:

public class MyClass { 
  int x; 
  
  void setX(int x) { 
    this.x = x; // sets the instance variable x
  } 
}

Is it helpful? Add Comment View Comments
 

Ques 7. What is the purpose of the 'static' keyword in Java?

'static' is used to create class-level variables and methods. It means the variable or method belongs to the class rather than a specific instance. 'static' members can be accessed using the class name.

Example:

Example:

class MyClass { 
  static int count; 
  
  static void incrementCount() { 
    count++; 
  } 
}

Is it helpful? Add Comment View Comments
 

Ques 8. Explain the concept of method overloading in Java.

Method overloading allows a class to have multiple methods with the same name but different parameters. The compiler determines which method to call based on the number and types of arguments passed.

Example:

Example:

class MathOperations { 
  int add(int a, int b) { 
    return a + b; 
  } 
  
  double add(double a, double b) { 
    return a + b; 
  } 
}

Is it helpful? Add Comment View Comments
 

Ques 9. What is the 'final' keyword in Java?

'final' is used to restrict the modification of classes, methods, and variables. A 'final' class cannot be inherited, a 'final' method cannot be overridden, and a 'final' variable cannot be reassigned after initialization.

Example:

Example:

public final class ImmutableClass { 
  // class definition
}

Is it helpful? Add Comment View Comments
 

Ques 10. Explain the concept of garbage collection in Java.

Garbage collection in Java automatically reclaims the memory occupied by objects that are no longer reachable. The 'java.lang.System.gc()' method and the 'finalize()' method are related to garbage collection.

Example:

No specific example, as garbage collection is a background process handled by the JVM.

Is it helpful? Add Comment View Comments
 

Most helpful rated by users:

©2025 WithoutBook