Java Interview Questions
Java Interview Questions
Java Basic
What is the JVM and what is its role in running Java applications ?
reference:
What is the difference between heap memory and stack memory in Java ?
How are objects stored in heap memory ?
reference:
Data Type
What are the different primitive data types in Java?
Can you give examples of implicit and explicit type casting with primitive data types?
reference:
Primitive Data Types (The Java™ Tutorials > Learning the Java Language > Language
Basics) (oracle.com)
The Numbers Classes (The Java™ Tutorials > Learning the Java Language >
Numbers and Strings) (oracle.com)
Autoboxing and Unboxing (The Java™ Tutorials > Learning the Java Language >
Numbers and Strings) (oracle.com)
Variable
How many type of variables in Java ? Can you differ among us ?
reference:
Variables (The Java™ Tutorials > Learning the Java Language > Language Basics)
What is the default value for uninitialized variables of different data types ?
What is the default value for uninitialized variables of different variable type ?
reference:
Operators (The Java™ Tutorials > Learning the Java Language > Language Basics)
(oracle.com) Array
How to convert an array to a string, each element of the array to a string, separates them with
commas, then surrounds them with brackets ?
Reference:
Arrays (The Java™ Tutorials > Learning the Java Language > Language Basics)
Reference:
Control Flow Statements (The Java™ Tutorials > Learning the Java Language >
Language Basics) (oracle.com)
OOP Concepts
Class and Object
How do you define a class, its member variables, methods, constructors in Java ?
Can you explain how to create and use objects of a class in Java ?
Reference:
What Is an Object? (The Java™ Tutorials > Learning the Java Language > Object-
Oriented Programming Concepts) (oracle.com)
What Is a Class? (The Java™ Tutorials > Learning the Java Language > Object-
Oriented Programming Concepts) (oracle.com)
OOP Principle
What are the four principles of OOP ?
Reference:
Encapsulation
Can you distinguish encapsulation, data hiding, immutabily ?
Reference:
Controlling Access to Members of a Class (The Java™ Tutorials > Learning the Java
Language > Classes and Objects) (oracle.com)
Inheritance
Can you explain The Java Platform Class Hierarchy ?
Why the Java programming language does not permit you to extend more than one class ?
What is Overriding and Hiding Methods in Inheritance with Instance methods, Static methods, Interface
Methods, Modifiers ?
Reference:
Inheritance (The Java™ Tutorials > Learning the Java Language > Interfaces and
Inheritance) (oracle.com)
Multiple Inheritance of State, Implementation, and Type (The Java™ Tutorials >
Learning the Java Language > Interfaces and Inheritance) (oracle.com)
Overriding and Hiding Methods (The Java™ Tutorials > Learning the Java
Language > Interfaces and Inheritance) (oracle.com)
Polymorphism
What is abstraction in Java and how is it achieved ?
Reference:
Polymorphism (The Java™ Tutorials > Learning the Java Language >
Interfaces and Inheritance) (oracle.com)
Writing Final Classes and Methods (The Java™ Tutorials > Learning the Java
Language > Interfaces and Inheritance) (oracle.com)
Abstraction
What is interface in Java ?
Reference:
Interfaces (The Java™ Tutorials > Learning the Java Language > Interfaces and
Inheritance) (oracle.com)
Abstract Methods and Classes (The Java™ Tutorials > Learning the Java Language >
Interfaces and Inheritance) (oracle.com)
String
String
What is a String in Java and how is it different from other data types?
What is the difference between String s = "abc"; and String s = new String("abc"); ?
Reference:
Reference:
- The StringBuilder Class (The Java™ Tutorials > Learning the Java Language >
Numbers and Strings) (oracle.com)
- StringBuilder (Java Platform SE 8 ) (oracle.com)
Collections
Collection overview
What is a Collections Framework ?
Reference:
List
What is the List Interface ?
Reference:
The List Interface (The Java™ Tutorials > Collections > Interfaces) (oracle.com)
ArrayList (Java Platform SE 8 ) (oracle.com)
The Queue Interface (The Java™ Tutorials > Collections > Interfaces)
Queue
What is the Queue Interface ?
Method of queue ?
Reference:
The Queue Interface (The Java™ Tutorials > Collections > Interfaces)
(oracle.com) The Deque Interface (The Java™ Tutorials > Collections >
Interfaces) (oracle.com)
Set
What is the Set interface ?
Reference:
The Set Interface (The Java™ Tutorials > Collections > Interfaces)
Map
What is the Map interface ?
Reference :
The Map Interface (The Java™ Tutorials > Collections > Interfaces)
Object ordering
What is the purpose of the Comparable interface in Java ?
Reference:
Reference:
Exception
Exception in Java
What is an exception in Java ?
Reference:
What Is an Exception? (The Java™ Tutorials > Essential Java Classes > Exceptions) (oracle.com)
Advantages of Exceptions (The Java™ Tutorials > Essential Java Classes >
Exceptions) (oracle.com)
Reference:
The Catch or Specify Requirement (The Java™ Tutorials > Essential Java Classes >
Exceptions) (oracle.com)
Reference:
Catching and Handling Exceptions (The Java™ Tutorials > Essential Java Classes >
Exceptions) (oracle.com)
Specifying the Exceptions Thrown by a Method (The Java™ Tutorials > Essential Java
Classes > Exceptions) (oracle.com)
How to Throw Exceptions (The Java™ Tutorials > Essential Java Classes >
Exceptions) (oracle.com)
JDBC
What is JDBC and why is it used in Java?