0% found this document useful (0 votes)
5 views7 pages

Java Running Notes

The document provides a comprehensive overview of key Java interview questions and answers, organized into various topics such as Core Java Basics, Java Platform Components, and OOP Concepts. It covers fundamental concepts like the Java language, JVM, access specifiers, inheritance, polymorphism, and more. Additionally, it includes explanations of Java features, memory areas, and examples of important outputs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views7 pages

Java Running Notes

The document provides a comprehensive overview of key Java interview questions and answers, organized into various topics such as Core Java Basics, Java Platform Components, and OOP Concepts. It covers fundamental concepts like the Java language, JVM, access specifiers, inheritance, polymorphism, and more. Additionally, it includes explanations of Java features, memory areas, and examples of important outputs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Here's a summary of the key Java Interview Questions and Answers extracted from your

document, grouped by topics:

📌 1. Core Java Basics

Q1: What is Java?

A: A high-level, object-oriented, platform-independent language developed by James Gosling in


1991.

Q2: Difference between C++ and Java?

A: Java is platform-independent, does not support multiple inheritance via classes, has built-in
garbage collection, and lacks features like operator overloading and explicit pointers.

📌 2. Java Platform Components

Q3: What is JVM?

A: Java Virtual Machine it is used to execute bytecode of java.

Q4: What are JDK, JRE, and JVM?

A:

 JVM:(Java Virtual Machine) used to execute the bytecode of java.


 JRE:(Java Runtime Environment) use to run the application.
 JDK: (Java development Kit) it is the tools to develop java application.

📌 3. Java Features

Q5: Key Java Features?

A: Simple, Object-Oriented, Portable, Platform Independent, Secure, Robust, Multithreaded,


High Performance, Distributed, Dynamic.
📌 4. Memory and Compilation

Q6: Memory areas by JVM?

A: Class Area, Heap, Stack, Program Counter Register, Native Method Stack.

Q7: What is JIT Compiler?

A: The Just-In-Time compiler converts Java bytecode (intermediate code) into machine code
at runtime (just before execution), so the program runs faster.

What is a Platform?

Ans: A platform is the environment in which a program runs or executes.

What are the main differences between the Java platform and other platforms?

Ans:  Java platform uses a JVM (Java Virtual Machine) to run programs — so the same
program can run on any OS.

 Other platforms (like Windows or Linux) run programs directly on the OS, so you may
need to change or recompile the program for each OS.

10) What gives Java its 'write once and run anywhere' nature?

Ans: Java’s "write once, run anywhere" feature is possible because Java code is compiled
into platform-independent bytecode, which runs on the Java Virtual Machine (JVM)
available on all major platforms.

What is a ClassLoader?

Ans: A ClassLoader in Java is a part of the Java Runtime Environment (JRE) that
loads Java classes into memory when your program runs.

What if I write static public void instead of public static void?

Ans: In Java, the order of modifiers like public and static doesn't matter.
What is the default value of local variables in Java?

Ans:

Local variables in Java do not have a default value.


You must initialize them before using them, or you will get a compile-time error.

What are the access specifiers in Java?

Access specifiers in Java are keywords used to control the visibility of classes, methods, and
variables.
There are four main access specifiers:

🔹 1. public

 The code is accessible from anywhere.


 Used when we want to make something globally available.

🔹 2. private

 The code is accessible only within the same class.


 Used for encapsulation and data protection.

🔹 3. protected

 Accessible in the same package and by subclasses in other packages.


 Commonly used in inheritance.

🔹 4. Default (no keyword)

 When no specifier is mentioned, it's accessible only within the same package.
 Called package-private access.
📌 5. Java Syntax and Keywords

Q8: What happens if no args are passed to main()?

A: The array is empty, not null.

Q9: Is delete, next, main, exit, or null a keyword in Java?

A: No.

📌 6. OOP Concepts

Q10: What is Object-Oriented Paradigm?

A: Programming centered around objects combining data and behavior.

Q11: Difference between object-oriented and object-based language?

A: Object-based languages don’t support inheritance/polymorphism.

📌 7. Constructors

Q12: What is a constructor?

A: Special method to initialize an object.

Q13: Types of constructors?

A: Default, Parameterized, Copy (simulated).

Q14: Is constructor inherited?

A: No.

Q15: Can constructors be static or final?

A: No.
📌 8. Static Keyword

Q16: What is a static variable?

A: Shared among all instances.

Q17: What is a static method?

A: Belongs to the class, not objects.

Q18: Can static methods access non-static variables?

A: No.

📌 9. Access Modifiers

Q19: Types?

A: Public, Protected, Default, Private.

📌 10. Inheritance & Super/This

Q20: What is inheritance?

A: Acquiring properties of a parent class.

Q21: this vs super?

A:

 this: Refers to current class.


 super: Refers to parent class.

📌 11. Aggregation vs Composition

Q22: Aggregation?

A: "Has-a" relationship. Weaker.


Q23: Composition?

A: Stronger form of aggregation. Lifespan dependency.

📌 12. Polymorphism

Q24: Method Overloading?

A: Same method name, different parameters.

Q25: Method Overriding?

A: Redefining a parent method in child class.

Q26: Can static methods be overridden?

A: No.

📌 13. Final Keyword

Q27: Final Variable?

A: Cannot be changed once assigned.

Q28: Final Method?

A: Cannot be overridden.

Q29: Final Class?

A: Cannot be inherited.

📌 14. Miscellaneous

Q30: What is object cloning?

A: Creating an exact copy of an object using clone().

Q31: What is instanceof?


A: Checks object type at runtime.

📌 15. Important Outputs and Examples

 System.out.println(10 + 20 + "Java") → 30Java


 System.out.println("Java" + 10 + 20) → Java1020
 Method overloading ambiguity: two methods with (int, long) and (long, int) can
cause compiler error.

If you'd like a printable or formatted table version or have a specific topic you'd like to dive
deeper into (e.g., OOP, Exception handling, Threads), let me know!

You might also like