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 vs Interpreted Language: Understanding the Process
More Relevant Posts
-
I’ve compiled 5000+ REAL-TIME Interview Questions asked in top companies like PwC, Cognizant, TCS, Infosys, Deloitte, EY & startups. 🚀 Not just a question bank — a Complete Interview Preparation System ✅ Detailed, beginner-friendly answers ✅ STAR method for real-time questions ✅ Confidence-building explanation guidance ✅ Lifetime access + doubt support + FREE updates 📚 Includes: Selenium | Java (300+ Programs) | Manual Testing | BDD Cucumber | SQL | API (Postman) | Rest Assured | Git | Jenkins | Jira | Agile | Playwright | Javascript | Typescript (Upcoming) ✔ 1500+ Selenium Practical Exercises ✔ 500+ API Testing Exercises ✔ 500+ Rest Assured Exercises ✔ 100+ Behavioural & Scenario-Based Questions ✔ Real-Time Projects (Banking + E-commerce) 👩💻 Perfect for Freshers | 1–6 Years | Manual → Automation Switch 🎁 ONE PDF = COMPLETE INTERVIEW PREPARATION 🔗 Notes Link:--- https://lnkd.in/dRMaNzSk
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)
To view or add a comment, sign in
-
🚀 Important Java Concepts Every Developer Should Know If you're learning Java or preparing for interviews, these core concepts are a must👇 🔹 OOP Principles Java is based on Object-Oriented Programming: ✔️ Encapsulation ✔️ Inheritance ✔️ Polymorphism ✔️ Abstraction 🔹 JVM, JRE, JDK Understanding how Java runs: ➡️ JVM executes bytecode ➡️ JRE provides runtime environment ➡️ JDK includes tools for development 🔹 Data Types & Variables Know the difference between: ✔️ Primitive (int, float, char, etc.) ✔️ Non-primitive (String, Arrays, Classes) 🔹 Exception Handling Handle errors using: ✔️ try-catch ✔️ finally ✔️ throw & throws 🔹 Collections Framework Important interfaces: ✔️ List ✔️ Set ✔️ Map 🔹 Multithreading Run multiple tasks simultaneously using threads 🔹 String Handling Remember: Strings are immutable in Java 💡 Mastering these basics builds a strong foundation for advanced Java development.
To view or add a comment, sign in
-
Why Java uses references instead of direct object access ? In Java, you never actually deal with objects directly. You deal with references to objects. That might sound small - but it changes everything. When you create an object: You’re not storing the object itself. You’re storing a reference (address) to where that object lives in memory. Why does Java do this? 1️⃣ Memory efficiency Passing references is cheaper than copying entire objects. 2️⃣ Flexibility Multiple references can point to the same object. That’s how shared data and real-world systems work. 3️⃣ Garbage Collection Java tracks references - not raw memory. When no references point to an object, it becomes eligible for cleanup. 4️⃣ Abstraction & Safety Unlike languages with pointers, Java hides direct memory access. This prevents accidental memory corruption. When you pass an object to a method, you’re passing the reference by value - not the object itself. That’s why changes inside methods can affect the original object. The key idea: Java doesn’t give you objects. It gives you controlled access to objects through references. #Java #JavaProgramming #CSFundamentals #BackendDevelopment #OOP
To view or add a comment, sign in
-
-
Java is quietly becoming more expressive This is not the Java you learned 5 years ago. Modern Java (21 → 25) is becoming much more concise and safer. 🧠 Old Java if (obj instanceof User) { User user = (User) obj; return user.getName(); } else if (obj instanceof Admin) { Admin admin = (Admin) obj; return admin.getRole(); } 👉 verbose 👉 error-prone 👉 easy to forget cases 🚀 Modern Java return switch (obj) { case User user -> user.getName(); case Admin admin -> admin.getRole(); default -> throw new IllegalStateException(); }; ⚡ Even better with sealed classes Java sealed interface Account permits User, Admin {} 👉 Now the compiler knows all possible types 👉 and forces you to handle them 💥 Why this matters less boilerplate safer code (exhaustive checks) fewer runtime bugs 👉 the compiler does more work for you ⚠️ What I still see in real projects old instanceof patterns manual casting everywhere missing edge cases 🧠 Takeaway Modern Java is not just about performance. It’s about writing safer and cleaner code. 🔍 Bonus Once your code is clean, the next challenge is making it efficient. That’s what I focus on with: 👉 https://joptimize.io Are you still writing Java 8-style code in 2025? #JavaDev #Java25 #Java21 #CleanCode #Backend #SoftwareEngineering
To view or add a comment, sign in
-
I thought my Java code was efficient… until it slowed down at scale. I was using this inside a loop: String result = ""; for (int i = 0; i < 10000; i++) { result += i; } Worked fine for small data. But with large input? Painfully slow. 💡 Why? Because Strings are immutable in Java. Every “+” creates a NEW object. So this loop created thousands of objects. The fix? Use StringBuilder: StringBuilder result = new StringBuilder(); for (int i = 0; i < 10000; i++) { result.append(i); } 💡 Deeper insight: Performance issues often hide in “simple” code. This wasn’t a syntax issue. It was a memory + object creation problem. ✅ Practical takeaway: In Java: • Use StringBuilder for loops • Avoid string concatenation in heavy operations • Think about object creation cost That one change made my code 10x faster.
To view or add a comment, sign in
-
Starting from JDK25, you can write a simple Java entry point (JVM main method) program as, ``` void main() { IO.println("Hello, World!"); } ``` and more interactively, ``` void main() { String name = IO.readln("Please enter your name: "); IO.print("Pleased to meet you, "); IO.println(name); } ``` 1. Both the above variants are single-file source-code programs (compact source file) 2. Automatically imports commonly used base packages such as java.io, java.math, and java.util via automatic import of the java.base module 3. To evolve a compact source file into a ordinary source file, all you need to do is wrap its fields and methods in an explicit class declaration and add an import declaration Assuming this program is in the file HelloWorld.java, you can run it directly with the source-code launcher: $ java HelloWorld.java Previously, the above simple Java program would look like below, ``` public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } } ``` where, 1. "public" access modifier & "class" declaration provides for proper encapsulation boundaries 2. "static" modifier provides for a class-object modelling 3. String[] args parameter provides for the program execution inputs 4. System.out.println provides utilities for printing to the console More details in the JEP512 - https://lnkd.in/g5JBAWwe advocating the simplification
To view or add a comment, sign in
-
-
How Garbage Collection actually works in Java ? Most developers know this much: “Java automatically deletes unused objects.” That’s true - but not how it actually works. Here’s what really happens: Java doesn’t delete objects randomly. It uses Garbage Collection (GC) to manage memory intelligently. Step 1: Object creation Objects are created in the Heap memory. Step 2: Reachability check Java checks if an object is still being used. If an object has no references pointing to it, it becomes eligible for garbage collection. Step 3: Mark and Sweep The JVM: • Marks all reachable (active) objects • Identifies unused ones • Removes those unused objects from memory Step 4: Memory cleanup Freed memory is reused for new objects. Here’s the key insight: Garbage Collection is not immediate. Just because an object has no reference doesn’t mean it’s deleted instantly. The JVM decides when to run GC based on memory needs. Java doesn’t magically manage memory. It uses smart algorithms to track object usage and clean up when needed. That’s what makes Java powerful - and sometimes unpredictable. #Java #JVM #GarbageCollection #CSFundamentals #BackendDevelopment
To view or add a comment, sign in
-
-
Day13 Today’s Java practice was about manipulating collections. I worked on reversing a map where keys become values and values become keys. This helped me get more comfortable with Map.Entry and iteration patterns. Small exercises like this strengthen fundamentals. Problem: Convert {A=1, B=2, C=3} into {1=A, 2=B, 3=C} Approach: ✔️ Traverse original map using entrySet() ✔️ Insert value as key and key as value into a new map Simple logic, but very helpful to understand key–value handling in Java. ================================================== // Online Java Compiler // Use this editor to write, compile and run your Java code online import java.util.*; class Main { public static void main(String[] args) { Map<String,Integer>map=new LinkedHashMap<String,Integer>(); map.put("A",1); map.put("B",2); map.put("C",3); System.out.println(map); Map<Integer,String>reverseMap=new LinkedHashMap<Integer,String>(); for(Map.Entry<String,Integer>data:map.entrySet()) { reverseMap.put(data.getValue(),data.getKey()); } System.out.println(reverseMap); } } Output:{A=1, B=2, C=3} {1=A, 2=B, 3=C} #JavaProgramming #AutomationLife #SoftwareTesting #LearningEveryday #TechSkills #CleanCode #DevelopersLife
To view or add a comment, sign in
-
-
#Java Why does Java not provide default value to local variables? 👉 Answer Java does not give default values to local variables to avoid using uninitialized (garbage) data and ensure safety. 📌 Example class Test { public static void main(String[] args) { int x; System.out.println(x); // ❌ Compile-time error } } ✔ Error: variable x might not have been initialized 📏 Rules (Simple Points) 🔒 Local variables must be initialized before use ❌ No default value is assigned by Java ⚠ Compiler checks this at compile time 📦 Instance & static variables get default values, but local variables do not 🎯 Summary 👉 Java forces initialization to prevent bugs and ensure clean code
To view or add a comment, sign in
-
#Java #Wrapper #Class Why we need Wrapper Class in Java ? 👉 Wrapper classes = convert primitive → object Examples: int → Integer, char → Character, double → Double ✅ Main Reasons (Simple Points) 1. 📦 Use in Collections Java collections like ArrayList, HashMap work with objects only ❌ Cannot use int ✅ Use Integer 👉 Example: ArrayList<Integer> list = new ArrayList<>(); 2. 🔄 Conversion (Primitive ↔ Object) Convert data easily int → Integer (Autoboxing) Integer → int (Unboxing) 3. 🧰 Utility Methods Wrapper classes provide useful methods 👉 Example: Integer.parseInt("123"); Double.valueOf("10.5"); 4. ❌ Handle Null Values Primitive cannot store null Wrapper can store null 5. 💾 Required in Frameworks Many frameworks (like Spring, Hibernate) need objects Wrapper classes are required
To view or add a comment, sign in
More from this author
-
What is Agentic QA
Software Testing Studio | WhatsApp 91-6232667387 3h -
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