Frequently Asking Question

In this Java Interview Questions blog, we have compiled some of the most essential Java Programming Interview Questions and Answers which helps you stand a chance in the interview process.

Get Java Training from experts. Call us @ +91 86087 00340 for a free demo session!

Java Interview Question and Answers

  1. Explain about Object oriented programming Language.
  2. Does Constructor Return any value?
  3. Can we overload main() method?
  4. What is marker interface?
  5. Can an Interface be final?
  6. What is Exception Handling?
  7. What are the two types of Exceptions in Java ?
  8. What is multithreading?
  9. What are the basic interfaces of Java Collections Framework
  10. What are the JDBC API components?
  11. What are the steps to connect to the database in java?
  12. What are the JDBC Statements?
  13. Super class of Java
  14. Does Java support Multiple Inheritance?
  15. Why String is Immutable Object?
  16. Nested Forloops
  17. Basic inheritance program
  18. What is gc?
  19. What is the Difference Between HashSet and TreeSet
  20. What is the Difference Between Collection and Collections?
  21. What is the life-cycle of a Servlet?
  22. What is JSP?
  23. What is over loading and over riding ?
  24. What is Abstraction and Encapsulation ?
  25. What is array?
  26. How to reverse string without using reverse Method?
  27. Features of java?
  28. Write a query how delete rows from mysql.
  29. Difference between truncate,delete,drop.
  30. What are the jdbc drivers.
  31. What is Dynmic binding.
  32. Difference between string and string buffer.
  33. What is class and object?
  34. What are the access modifer in java?
  35. Difference between local and global variable.

1.Explain about Object Oriented Programming Language

Object-Oriented Programming is a methodology or paradigm to design a program using classes and objects. It simplifies the software development and maintenance.

2.Does Constructor Return any Value?

when you call the constructor using a new keyword you get an object. Though it doesn’t explicitly return something but instead it creates or constructs something which you can use as an instance of a class. yes, it is the current class instance. (We cannot use return type yet it returns a value).

3.Can we Overload main() method?

yes we can overload main method. main method must not be static main method. Yes, main method can be overloaded.

4.What is Marker Interface?

A marker interface in Java is an interface with no fields or methods. Put more simply, an empty interface in Java is called a marker interface. Examples: Serializable , Cloneable and Remote interfaces.

5.Can an Interface be Final?

An interface is a pure abstract class. Hence, all methods in an interface are abtract, and must be implemented in the child classes. So, by extension, none of them can be declared as final

6.What is Exception Handling?

An unexpected event that disturbs the normal flow of program.

7.What are the two types of Exceptions in Java ?

  1. checked Exception
  2. Unchecked Exception

8.What is Multithreading?

Multithreading in java is a process of executing multiple threads simultaneously. A thread is a lightweight sub-process, the smallest unit of processing. Multiprocessing and multithreading, both are used to achieve multitasking.

9.What are the Basic Interfaces of Java Collections Framework

Java Collection means a single unit of objects. Java Collection framework provides many interfaces (Set, List, Queue, Deque) and classes (Array List, Vector, Linked List, Priority Queue, HashSet, Linked HashSet, TreeSet).

10.What are the JDBC API Components?

The JDBC API. The JDBC API gives access of programming data from the Java. JDBC Driver Manager. The JDBC Driver Manager is the class in JDBC API. JDBC Test Suite. JDBC-ODBC Bridge.

11.What are the Steps to Connect to the Database in Java?

  • Step 1: Register the Driver class
  • Step 2: Create connection
  • Step 3: Create statement
  • Step 4: Execute queries
  • Step 5: Close connection

12.What are the JDBC Statements?

It can be used for general-purpose access to the database. It is useful when you are using static SQL statements at Run time.

Prepared Statement:
It can be used when you plan to use the same SQL statement many times. The Prepared Statement interface accepts input parameters at Run time.

Callable Statement:
Callable Statement can be used when you want to access database stored procedures.

13.Super Class of Java

The super keyword in Java is a reference variable which is used to refer immediate parent class object.

14.Does Java Support Multiple Inheritance

No..Java Does not Support Multiple in hesitance. Once string object is created its data or state can’t be changed but a new string object is created.

15.Why String is Immutable Object?

In Java, string objects are immutable. Immutable simply means unmodifiable or unchangeable.

16.Nested For loops

Class For
public static void main(String [] args)
for(int i=0;i<5;i++)
for(int j=0;j<=i;j++)

17.Basic Inheritance Program

Class A
public void add()
class B extends A
public static void main(String [] args)
A ob=new A();

18.What is gc?

UN Reachable objects in program automatically eligible for garbage collection.

19.What is the difference between HashSet and TreeSet

TreeSet : tree set is faster performance compare to hashset. HashSet : hash set not maintain insertion order.but tree set maintain ascending order of elements.

20.What is the difference between Collection and Collections?

Collection is a interface and Collections is a class. both are contains in util package.

21.What is the life-cycle of a servlet?

  • Init
  • Service
  • Destroy

22.What is JSP?

Java server page used for front end development. method overloading programm and methos overriding and differences

23.What is over loading and over riding

Overloading: same method but differnt parameters.
Overriding: same method name in different class.

24.What is Abstraction and Encapsulation

Abstraction:hiding internal implementation.
Encapsulation:wrapping of data in single unit.

25.What is Array?

Collection of homogenous datatypes.

26.How to reverse string without using reverse method

String s=”java”
for(int i=s.length()-1;i>=0;i++)

27.Features of java

  • platform indepdent
  • object oriented
  • high performance
  • secured

28.Write a query how Delete Rows from mysql

delete from table(name) where (row)=;

29.Difference between Truncate, Delete, Drop

Truncate: total rows from table
Drop: to delete the table from database
Delete: particular row from table

30.What are the jdbc drivers

  • JDBC-ODBC Bridge.
  • Native api
  • Network protocol
  • Thin driver

31.What is Dynmic Binding

From the reference of base class we can create object to derived class

32.Difference between string and string buffer

String is an immutable object
String buffer is an mutable Object

33.What is class and object

Class is blue print of program
object is an reference of class

34.What are the access modifer in java

  • Public
  • Private
  • Protected
  • Default

35.Difference between local and global variable

Local Variable Declared in side method
Global Variable Declared inside class out side method

Hope you have gone through these 35 Interview Questions with diligence. It is not only a learning experience but also helps you to crack the interview with confidence. Happy Java Job Searching!