java programming interview questions and answers
Tech Interview

Java Programming Interview Questions


These Java programming interview questions have been designed especially for the beginner. I have listed the basic concept of the subject.

1. What are the significant features of OOP?

The significant features of OOP are

2. What is Java Virtual Machine?

A Java virtual machine is also known as JVM, which  is an abstract computing machine that enables a computer to run Java bytecodes. Each source file of Java is compiled into bytecode files which is executed by the JVM.

3. What does static keyword mean?

The static keyword in Java is mainly used for memory management. Static keyword can be applied with methods, blocks, variables and nested class.

4. What is static variable?

If a variable is declared as static, then it is known as static variables. The static variable can be used to refer the common property of all the objects. It gets memory only once in the class area at the time of class loading.

5. What are the data type supported by java?

The primitive data type supported by java is

  • int
  • long
  • float
  • double
  • boolean
  • char
  • byte
  • short

6. Does java support multiple inheritance?

No, Java doesn’t support multiple inheritance.

7. What is the difference between public,private and protected?

  • Public: Accessible to all classes.
  • Private: Accessible only to the class to which they belong.
  • Protected: Accessible to the class to which they belong and to any subclasses.

8. Define garbage collection ?

Garbage collection is also called as automatic memory management. As it automatically removes the unused variables and objects. garbage collection is an automatic process and you can request it by calling System.gc().

9. what is the usage of Java package?

Java package helps to organize files when a project consists of multiple modules. It also helps to resolve naming conflict when different packages have classes with same names.

READ  Help Desk Interview Questions

10. Explain the main difference between a vector and an ArrayList?

ArrayList is not synchronized and Java vector class is internally synchronized.

11. What is the output of the below statement?

12. Write a program to print prime number in Java?

13. what is the difference between thread and process?

A thread is a single execution sequence within a process while a process is an execution of a program. A thread is sometimes called a lightweight process.

14. What are Wrapper classes?

Wrapper classes are the classes that allow primitive type to be accessed as objects.

15. what is the local variable default value?

It has  neither primitives nor object references and it is not initialized to any default value.

READ  ASP.NET Interview Questions

java programming interview questions and answers

16. What is JDBC?

JDBC is defined as Java Database Connectivity. It is a Java API used to interact with different varieties of database from a Java application.

17. What is meant by Encapsulation?

It is defined as a process of wrapping the data and code together into a single unit.

18. Write a program to get a given string in reverse order?

19. What is Ternary operator?

The ternary operator is also known as called as conditional operators are used to decide which value to assign to a variable. Assigning is based on a Boolean value evaluation.

20. What is meant by pivot?

Pivot is an operator used to convert rows into column dynamically.

21.What is the output of the below statements?

22. What are two types of exception handling in Java?

  • checked exceptions
  • unchecked exceptions
READ  Active Directory Interview Questions

23. Life cycle of Applet?

  • Init
  • Start
  • Stop
  • Destroy

24. Which swing methods are thread safe?

  • Repaint,
  • Invalidate.
  • Revalidate

25. List the layers of RMI Architecture?

  • Stub and Skeleton layer
  • Remote Reference Layer
  • Transport layer