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 Questions

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.
  36. What is JavaScript and its features?
  37. What is the importance of JavaScript?
  38. Is JavaScript needed?
  39. Is it important to learn JavaScript?
  40. Is Python better than JavaScript?
  41. Does JavaScript have a future?
  42. What are the two types of Java programs?
  43. What are the features of Java?
  44. What are the 4 types of JDBC drivers?
  45. What is a Java driver?
  46. What are the steps required to run a query in JDBC?
  47. What is JDBC Addbatch?
  48. Which interface provides methods for batch processing in JDBC?
  49. What is the connection interface in JDBC?
  50. What is the difference between a Java application and a Java applet?

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?

Statement:
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++)
{
System.out.print(“*”);
}
System.out.Println();
}
}
}

17.Basic Inheritance Program

Class A
{
public void add()
{
System.out.println(“hi”);
}
class B extends A
{
public static void main(String [] args)
{
A ob=new A();
ob.add();
}
}

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++)
{
System.out.print(CharAt(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

36.What is JavaScript and its features?

Features of JavaScript. JavaScript is a client side technology, it is mainly used for gives client side validation, but it have lot of features which are given below; JavaScript is a object-based scripting language. Giving the user more control over the browser. … JavaScript is interpreter based scripting language.

37.What is the importance of JavaScript?

Importance Of JavaScript. JavaScript, an object scripting language which is used in web pages along with markup language HTML. JavaScript is very popular and adopted universally by every web browser for its support which allows dynamic content to get execute in a webpage.

38.Is JavaScript needed?

All you need to do is change one little setting in your browser of choice. Just un-tick the checkbox that enables “JavaScript” and away you go, to a simpler, cleaner web. JavaScript is a programming language that can run inside nearly all modern web browsers.

39.Is it important to learn JavaScript?

What is JavaScript, and why is it important? JavaScript is a programming language used primarily by Web browsers to create a dynamic and interactive experience for the user. Most of the functions and applications that make the Internet indispensable to modern life are coded in some form of JavaScript.

40.Is Python better than JavaScript?

Python is a better-designed language which makes it easy to maintain whereas JavaScript is poor. Python is not good for mobile development whereas Java-Script is good. Python is slow to run comparatively to JavaScript. … JavaScript runs on both browser and server whereas python is mostly used for server-side programming.

41.Does JavaScript have a future?

The future is JavaScript. In addition to its front-end domain, JavaScript is reaching everything from browsers to tablets, phones and desktop computers. Although any language can be tailored to the server and client-side with the correct implementation, JavaScript is the only one at this time that offers a practical way to do both.

42. What are the two types of Java programs?

There are many types of Java programs that run differently: Java Applet: small program written in Java that is downloaded from a website and run inside a Web browser on a client computer Application: run on a client computer.

43. What are the features of Java?

Here are the main features of Java: * Simple: Java language is easy to learn. … * Familiar: Java is similar to C / C ++, but it eliminates the disadvantages and complexities of C / C ++ as pointers and several inheritances. … * Object-oriented: … * Robust: … * Of course: … * High performance: … * Multiprocess: … * Platform independence.

44. What are the 4 types of JDBC drivers?

There are 4 types of JDBC drivers: JDBC-ODBC bridge driver Native API driver (partially java driver) Network protocol driver (fully java driver) Driver Slim (fully java driver)

45.What is a Java driver?

A “driver class” is usually just the class that contains a main. In a real project, you can often have multiple “Driver Classes” for testing and other things, or you can create a main on any of your objects and select the executable class through your IDE or simply by specifying “java classname” .

46. What are the steps required to run a query in JDBC?

The key steps involved in the process of connecting to a database and running a query are as follows: Import JDBC packages. Load and register the JDBC driver. Open a connection Create a declaration object to execute a query, run the declaration object, and return a query result set.

47. What is JDBC Addbatch?

JDBC – Batch Processing. … The method will return true if your JDBC driver supports this function. The addBatch () method of Statement, PreparedStatement, and CallableStatement is used to add individual statements to the batch. The executeBatch () is used to start executing all grouped declarations.

48.Which interface provides methods for batch processing in JDBC?

Batch processing in JDBC. Instead of executing a single query, we can execute a batch (group) of queries. This makes the performance fast. The java.sql.Statement and java.sql.PreparedStatement interfaces provide methods for batch processing.

49.What is the connection interface in JDBC?

Connection interface. A Connection is the session between java application and database. The Connection interface is a factory of Statement, PreparedStatement, and DatabaseMetaData i.e. object of Connection can be used to get the object of Statement and DatabaseMetaData.

50.What is the difference between a Java application and a Java applet?

What is the difference between applets and an application. … An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included. An application is a standalone Java program that runs as a true application, outside of a browser.