Introduction to Java - Questions & Answers
2 MARK QUESTIONS & ANSWERS
Q: What is Java?
A: Java is a high-level, object-oriented, platform-independent programming language.
Q: Who developed Java?
A: Java was developed by James Gosling at Sun Microsystems.
Q: What is JVM?
A: JVM is a virtual machine that executes Java bytecode.
Q: What is JDK?
A: JDK is a development kit that includes JRE and tools like compiler.
Q: What is JRE?
A: JRE provides the environment to run Java programs.
Q: Define platform independence.
A: Java programs can run on any system with JVM.
Q: What is bytecode?
A: Intermediate code generated after compilation.
Q: What is a class?
A: A class is a blueprint for creating objects.
Q: What is an object?
A: An object is an instance of a class.
Q: Write syntax of main method.
A: public static void main(String[] args)
Q: What is WORA?
A: Write Once Run Anywhere.
Q: What is encapsulation?
A: Wrapping data and methods into a single unit.
Q: What is inheritance?
A: Acquiring properties of another class.
Q: What is polymorphism?
A: Same method behaving differently.
Q: What is abstraction?
A: Hiding internal implementation details.
5 MARK QUESTIONS & ANSWERS
Q: Explain features of Java.
A: Java is simple, object-oriented, platform independent, secure, robust, multithreaded and
distributed.
Q: Write a simple Java program.
A: class Hello { public static void main(String[] args){ [Link]('Hello'); }}
Q: Explain compilation and execution.
A: Java code is compiled using javac into bytecode, then executed using JVM.
Q: Differentiate JDK, JRE, JVM.
A: JVM executes code, JRE runs programs, JDK develops programs.
Q: Explain history of Java.
A: Java was developed in 1995, originally called Oak, later renamed Java.
Q: Explain OOP concepts.
A: OOP includes class, object, inheritance, polymorphism, encapsulation, abstraction.
Q: Explain platform independence.
A: Java bytecode runs on JVM making it OS independent.
Q: Structure of Java program.
A: Includes class, main method, statements.
Q: Advantages of Java.
A: Portable, secure, robust, multithreaded.
Q: Explain OOP principles.
A: Encapsulation, inheritance, polymorphism and abstraction.