Is Java a compiled language or an interpreted one? Both. Confused? Yes, Java is both compiled as well as interpreted language. This is what makes it platform-independent. Java Code >> Compile (javac) >> Bytecode (portable code) >> Interpret (platform specific) >> Machine Code >> Execute. Normal: 1. Java Compiler (javac) compiles Java code to Bytecode (which is platform-independent). 2. Java Interpreter (java) interprets this bytecode (line-by-line) & convert it to Machine language. 3. Execute. Exception: JIT (Just In Time) Compiler 1. JVM maintains the count for no of times a function is executed. 2. If it exceeds the limit then JIT directly compiles the Java code into Machine language. No Interpretation. In General, • Compile: Source code >> Optimized Object Code (can be machine code or other optimized code) • Interpret: Source Code >> Machine Code (to be executed)
Java: Compiled and Interpreted Language
More Relevant Posts
-
Day 4 :2-03-2026 Dynamic input means taking input from the user while the program is running (at runtime), instead of giving fixed values inside the program. In Java, dynamic input allows the program to accept data such as numbers, text, or characters from the user during execution. It makes the program flexible and interactive. The value is not predefined; it changes based on user input. For example (conceptually): The user enters their name → program stores it. The user enters a number → program performs calculation. Java Syntax (Only Syntax, No Example Program) In Java, dynamic input is commonly taken using the Scanner class from the java. util package. Import Statement import java. util. Scanner; Create Scanner Object Scanner variable Name = new Scanner(System.in); Methods to Take Input For integer: variable Name. nextInt(); For float: variableName.nextFloat(); For double: variableName.nextDouble(); For single word (String): variableName.next(); For full line (String): variableName.nextLine(); Short Definition (Exam Point) Dynamic input in Java means accepting user data at runtime using input classes like Scanner.
To view or add a comment, sign in
-
-
🔹FUNDAMENTALS OF JAVA 🔥 Why is main() method must in java? When you run: java Run JVM: 1️⃣ Loads the class Run 2️⃣ Searches for: public static void main(String[] args) 3️⃣ If found → Execution starts 4️⃣ If not found → Error ________________________________________ ❌ What Happens If main() Is Missing? Example: class Test { static void show() { System.out.println("Hello"); } } Compile works ✔ But when running: java Test You get error: Error: Main method not found in class Test Because JVM cannot find main().
To view or add a comment, sign in
-
-
Pattern matching with instanceof Hi all, in this post under Java pattern matching section, I will introduce you to pattern matching and how to use it with instanceof operator. Please don't confuse java pattern matching with regex pattern matching Regex pattern matching checks whether a given text matches a text pattern and may optionally extract parts of the text. Whereas Java pattern matching checks whether a given object matches a particular type, shape, or structure and if it matches, it binds the value to variables so that the information can be extracted....
To view or add a comment, sign in
-
Basic Java Questions That Every Developer Should Know 1️⃣ Why is Java not considered a pure object-oriented language? 💡 Hint: Think about primitive data types. 2️⃣ What is the difference between == and .equals() in Java? 💡 Hint: Reference vs value comparison. 3️⃣ Why is the main() method declared as static in Java? 💡 Hint: Think about how the JVM calls it. 4️⃣ What is the difference between String, StringBuilder, and StringBuffer? 💡 Hint: Mutability and thread safety. 5️⃣ Why doesn’t Java support multiple inheritance with classes? 💡 Hint: The famous Diamond Problem. 6️⃣ What is the difference between JDK, JRE, and JVM? 💡 Hint: Think about development vs execution. 7️⃣ What is the difference between ArrayList and LinkedList? 💡 Hint: Internal data structure and performance. 8️⃣ What happens if you don’t override hashCode() when you override equals()? 💡 Hint: Think about HashMap behavior. 9️⃣ What is the difference between final, finally, and finalize in Java? 💡 Hint: They belong to completely different concepts. 🔟 Why are Strings immutable in Java? 💡 Hint: Security, caching, and thread safety. 💬 Follow for more Java interview questions and system design concepts. 📩 Feel free to drop me a message if you'd like to discuss any interview question. #Java #Programming #SoftwareEngineering #InterviewPreparation #JavaDeveloper
To view or add a comment, sign in
-
-
Mutable vs Immutable Strings in Java Strings are widely used in Java. Based on modification ability, they are classified into Immutable and Mutable. 🔹 Immutable String (String) An Immutable String cannot be changed after creation. Any modification creates a new object. 📌 Example: Java Copy code String s = "Hello"; s = s.concat(" World"); ✅ Features: • Cannot be modified • Creates new object on change • Stored in String Constant Pool • Memory efficient & secure 🔹 Mutable String (StringBuilder / StringBuffer) A Mutable String can be modified without creating a new object. 📌 Example: Java Copy code StringBuilder sb = new StringBuilder("Hello"); sb.append(" World"); ✅ Features: • Can be modified • Same object is updated • Faster for frequent changes • Better performance 🔹 Key Difference Immutable Mutable Cannot change Can change New object created Same object modified Uses String Uses StringBuilder / StringBuffer 🚀 Conclusion: Use String for fixed data. Use StringBuilder/StringBuffer for frequently changing data.
To view or add a comment, sign in
-
-
📌 Why Java Doesn’t Support Multiple Inheritance (And How It Solves the Problem) One of the most common Java interview questions: Why doesn’t Java support multiple inheritance? Let’s understand the real reason. 🤯 The Problem – The Diamond Problem Imagine this: class A { void show() { System.out.println("From A"); } } class B extends A { } class C extends A { } // Now what if: class D extends B, C { } // ❌ Not allowed in Java Now think carefully. If both B and C inherit show() from A,and D inherits from both… 👉 Which show() should Java call? This ambiguity is called the Diamond Problem. Languages like C++ allow this and resolve it differently. Java decided to avoid this confusion entirely. 🚫 So Java Does NOT Allow: class D extends B, C No multiple inheritance with classes. ✅ But Java Still Allows Multiple Inheritance (Smartly) Through Interfaces. interface A { void show(); } interface B { void show(); } class D implements A, B { public void show() { System.out.println("Resolved in D"); } } Here: - No ambiguity - No inherited implementation conflict - Child class provides implementation - Clean. Explicit. Safe. 🔥 What About Default Methods? (Java 8+) - Java 8 introduced default methods in interfaces. - Now the ambiguity can reappear. - Java handles it like this: - If two interfaces provide the same default method, the implementing class must override it. - Explicit resolution. - No confusion. #Java #OOP #SoftwareEngineering #InterviewPreparation #JavaDeveloper
To view or add a comment, sign in
-
-
🚀 Java Series (2) – Understanding Java Variables (With JVM Memory Mapping) In Java, a variable is a name given to a memory location. It acts like a container that stores data during program execution. 👉 Variable = “vary + able” Meaning: Its value can change. Every variable must have a data type, which defines what kind of data it can store. 🎯 Types of Java Variables 1️⃣ Local Variables 2️⃣ Instance Variables 3️⃣ Static Variables Let’s understand them clearly — and where they are stored inside the JVM. 1️⃣ Local Variable 📌 Declared inside: Method Constructor Block 🔹 Characteristics • Created when method is called • Destroyed when method ends • Must be initialized before use • Scope limited to method/block 📍 Stored In JVM: 👉 Stack Memory When a method is invoked: A new stack frame is created Local variables are stored inside that frame When method completes → frame is removed 2️⃣ Instance Variable 📌 Declared inside class but outside methods. 🔹 Characteristics • Belongs to object • Each object has its own copy • Gets default values • Created when object is created 📍 Stored In JVM: 👉 Heap Memory Object stored in Heap Instance variables stored inside that object Reference variable (s) stored in Stack 3️⃣ Static Variable 📌 Declared using static keyword. 🔹 Characteristics • Belongs to class (not object) • Only one copy exists • Shared among all objects • Loaded once when class is loaded 📍 Stored In JVM: 👉 Method Area (Class Area) Static variables are stored in: Method Area Along with class metadata They are created when class is loaded by ClassLoader.
To view or add a comment, sign in
-
-
Simple code. Subtle behavior. Easy to misjudge. Two similar Java methods. Two completely different outputs. Case 1-> public static int tricky1() { int x = 10; try { return x; } finally { x = 50; } } Output: 10 Explanation: When return x executes, Java evaluates and stores the value (10) first. After that, the finally block runs. Even though x becomes 50 inside finally, it does not change the already prepared return value. Case 2-> public static int tricky2() { try { return 10; } finally { return 30; } } Output: 30 Explanation: If finally contains a return statement, it overrides any previous return from try or catch. This is why returning from finally is considered bad practice — it can override results and even hide exceptions. #Java #CoreJava
To view or add a comment, sign in
-
There is quiet change in Java that every Java Developer should know about👀 I still remember the first Java program I ever wrote like every beginner, I memorized this line like a ritual : `public static void main(String[] args)` But here’s the surprising part In modern Java (21+), you can now write: void main() { System.out.println("Hello World"); } Yes… no `static`. 😮 So what actually changed? **Old JVM behaviour** When a Java program starts: 1️⃣ JVM loads the class 2️⃣ No objects exist yet 3️⃣ JVM looks for a method it can call directly Since non-static methods need an object, Java forced us to use a static `main()`. That’s why we all memorized that signature. But in Modern JVM behavior (Java 21 → 25) JVM quietly does this behind the scenes: ```java new Main().main(); ``` It creates the object and calls the method for you. This change actually pushes Java closer to being more object-oriented, because now your program can start from an instance method instead of a static one. Next time, let’s discuss a fun debate Why Java is still NOT a 100% Object-Oriented language. Did you know this change already happened? #Java #Programming #JVM #SoftwareEngineering #Developers
To view or add a comment, sign in
-
More from this author
-
What is Agentic QA
Software Testing Studio | WhatsApp 91-6232667387 18h -
Interview #442: Postman - How do you manage different environments like QA, UAT, and Production?
Software Testing Studio | WhatsApp 91-6232667387 1d -
Interview #441: How do you compare API response data with database data?
Software Testing Studio | WhatsApp 91-6232667387 2d
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development