Java Introduction - Interview Questions & Features
Interview Questions & Answers
1. What is Java?
Java is a high-level, class-based, object-oriented programming language developed by Sun
Microsystems (now owned by Oracle). It follows the principle of "Write Once, Run Anywhere."
2. What are the features of Java?
Platform Independent, Object-Oriented, Simple and Secure, Robust, Multithreaded, Architecture
Neutral, Portable, High Performance.
3. Why is Java platform independent?
Because Java code is compiled into bytecode which can run on any system with a JVM.
4. What is JVM, JRE, and JDK?
JVM: Executes Java bytecode.
JRE: JVM + libraries.
JDK: JRE + development tools.
5. What is bytecode in Java?
Bytecode is the intermediate code generated by the Java compiler. It's platform-independent and
executed by the JVM.
6. Is Java compiled or interpreted?
Java is both. Code is compiled to bytecode, then interpreted or compiled by the JVM.
7. What is the difference between Java and C++?
Java is platform-independent and uses automatic memory management. C++ supports pointers and
manual memory management.
8. What is the Java Virtual Machine (JVM)?
JVM is a part of the JRE that executes Java bytecode and provides a platform-independent runtime.
9. What is the main method in Java?
It's the entry point of any Java application: public static void main(String[] args)
10. Why is Java considered secure?
No pointers, runs in sandbox environment, and uses a security manager.
Features of Java - Explained
Simple
Java is easy to learn and removes complex features like pointers and operator overloading.
Object-Oriented
Java supports OOP principles such as Encapsulation, Inheritance, Polymorphism, and Abstraction.
Platform Independent
Java code compiles to bytecode which can run on any device with a JVM.
Secure
Java eliminates pointers, runs in a sandbox, and uses a security manager to define class access.
Robust
Java has strong memory management and exception handling to build reliable applications.
Multithreaded
Java can run multiple threads simultaneously for tasks like gaming and server processing.
Architecture Neutral
Java bytecode is independent of the system architecture, making it flexible.
Portable
Java programs can run on different platforms without modification.
High Performance
JIT compiler helps Java achieve high performance by converting bytecode to native code at runtime.
Distributed
Java supports network-based applications and technologies like RMI and CORBA.