Java Core Interview Questions - Short
and Clear Answers
What is Java?
Java is a high-level, object-oriented programming language developed by Sun Microsystems.
What are the features of Java?
Platform-independent, Object-oriented, Secure, Robust, Multithreaded, High performance.
Explain JVM, JRE, and JDK.
JVM runs Java bytecode. JRE = JVM + libraries. JDK = JRE + development tools.
Difference between JDK and JRE.
JDK includes JRE plus development tools. JRE is just to run Java programs.
What is bytecode?
Bytecode is the intermediate code generated by the Java compiler, executed by JVM.
Why is Java platform-independent?
Because Java bytecode runs on JVM, which is available for all platforms.
What are identifiers and literals?
Identifiers are names (like variables), literals are constant values (like 10, 'A').
What are access modifiers in Java?
They define access scope: public, private, protected, default.
Difference between == and .equals() in Java.
== compares reference; .equals() compares values.
What is a variable in Java?
A variable is a container that holds data during program execution.
What are the primitive data types in Java?
byte, short, int, long, float, double, char, boolean.
What is type casting in Java?
Converting one data type into another.
Difference between implicit and explicit casting?
Implicit is automatic; explicit needs manual type conversion.
Explain arithmetic and logical operators.
Arithmetic: + - * / %, Logical: && || !
Difference between increment (++) and decrement (--) operators.
++ increases value by 1, -- decreases value by 1.
Explain if-else and switch statements with examples.
Both are conditional statements. if-else checks conditions, switch selects based on value.
Difference between while and do-while loops.
while checks before loop, do-while checks after execution.
What is a for-each loop?
Enhanced loop to iterate over arrays/collections.
How does break and continue work?
break exits loop; continue skips current iteration.
What is a nested loop?
A loop inside another loop.
What is object-oriented programming?
Programming using classes and objects. Based on encapsulation, inheritance,
polymorphism, abstraction.
Explain the concept of class and object.
Class is a blueprint. Object is an instance of a class.