LCWD LogoLearn Code With DurgeshLCWD
HomeCoursesBlogsContact
About LCWDAbout Durgesh Tiwari
Flex Box Hero
LearnCodeWithDurgesh Logo

Learn Code With Durgesh

Offering free & premium coding courses to lakhs of students via YouTube and our platform.

Explore

  • About Us
  • Courses
  • Blog
  • Contact
  • FlexBox Game

Legal

  • Privacy Policy
  • Terms & Conditions
  • Refund Policy
  • Support

Contact

  • 📞 +91-9839466732
  • [email protected]
  • Substring Technologies, 633/D/P256 B R Dubey Enclave Dhanwa Deva Road Matiyari Chinhat, Lucknow, UP, INDIA 226028
© 2025 Made with ❤️ by Substring Technologies. All rights reserved.
Most Asked Java Interview Question

Most Asked Java Interview Question

By durgeshkumar8896 • Sun Oct 09 2022

Most Asked Java Interview Question

Java is a programming language developed by James Gosling which needs no introduction. JIt is the most loved programming language and always in demand. Knowing java, you can land up a well paying job.

So here are some very important and most asked questions related to Java which can help you crack any interview.

What is Java?

Java is a general purpose,object oriented,platform independent  programming language which follows the WORA(Write  Once Run Anywhere) concept which means it can be written on any platform and run on any platform.

Java_logo

Difference between JDK,JRE,JVM?

JDK is a software development kit that comes with all the required tools libraries for compiling,debugging, testing and executing java programs. Some of these are javac, javadoc,javaw,jdb etc.

JRE provides a runtime environment for your program to run.

JVM is a Java virtual machine (CPU) which understands the compiled code of java(Bytecode).


JVM interprets the code which is already compiled and converted into Bytecode and converts it to machine code.

Java development kit

Java runtime environment

Java virtual machine

Java_config

Unique features of Java?

  1. Least undefined behavior/Robust: Java shows very less undefined behaviors, undefined behaviors means behaving in an unexpected way like crash of the program,etc.

  2. Automated Memory management: Java provides us automatic garbage collection support that means it allocates the memory when needed and deallocates when not in use. And this process happens automatically in the background.

  3. Platform Independence: In java, we write the code which basically executes on a java virtual machine and not on any physical machine(and this is the reason for java being slow). And JVM understands the bytecode(code generated by java compiler) which does not depend on any underlying OS or architecture.It will understand the bytecode generated on any machine. So you can compile java code on any OS, and take the bytecode to any other OS and run. This is why java is called platform independent.

  4. Dependency manager:  We have tools like maven, gradle which can download dependencies from online repositories. Dependencies help you in reusing code you need, which is already developed by other users in their production, so that you don’t have to write the same code again.

What is class and object?

Class: Class is a blueprint  of an object which has its own data member(properties) and methods(behavior). In other words, the class contains properties of real objects and functions of real objects(what object can perform).

Object: Object is the real world entity which has its own properties and behavior. Or we can say an object is an instance of class. It will have the same properties and functions which are defined in the class.

What are wrapper classes in Java?

 As we know everything in java is in the form of class and objects except primitive data types. So Java introduced a wrapper class to wrap them also with these classes. A wrapper class is a class whose objects  wrap/contain primitive data types; these wrapper classes are used to convert primitive data types into their corresponding objects.

Why is the Java platform independent?

As we know, java compiler compiles the code and generates bytecode. Bytecode is a set of instructions a “virtual CPU(JVM)” requires to run a program. And this is why java is platform independent. You can take the bytecode to any platform and execute if it has JVM. Remember, Bytecode is platform independent, but once the bytecode is converted into machine code by JVM, It is dependent on the platform.

Why is Java not 100% Object-oriented?

Java is not 100% object oriented. Object oriented means everything should be in the form of class and objects which java definitely does.But, Java also supports primitive data types like int, byte, long etc which are not objects. Hence java is not considered as 100% platform independent.

What are constructors in Java?

Constructors are a special method of class which is used to initialize instance members of a class. Constructors have 2 properties,

  1. It has no return type like methods.

  2. It always has the same name as the class name.

  3. Constructors are of two types: Parameterize and non-parameterize.

What is this keyword?

  • This keyword is used to differentiate between local variables and instance variables.

  • This keyword is used to call a constructor of the same class from another constructor of the same class.

  • This keyword is used to refer to the current invoking object of the class.

What is a super keyword?

  • Super keyword is used to refer to an intermediate parent class instance member.

  • Super keyword is also used to refer to intermediate parent class methods.

  • Also super keywords can be used to call intermediate parent class constructor.

What are the Memory Allocations available in Java?

Memory allocation is a process by which computer programs are assigned physical or virtual memory spaces.

In java, memory is divided into 3 types:

  • Stack area: Local variables and reference variables get memory in stack area
  • Heap area:Objects get memory from heap area
  • Class area: Static variables and static methods get memory in class area.

What is a Package?

Packages are the logical containers which contain classes and interfaces, the packages are used to separate one type of class from another.

What is the final keyword?

  • Final keyword is used with a variable to make the value of any variable constant.

  • Final keyword is used with classes to prevent inheritance. Finals class can not be inherited by any other class.

  • Final keyword used with the method can prevent overriding of the method.

Explain constructor Overloading.

Whenever there are more than one constructor but the number of arguments or order or type of argument is different in the same class, then it is called constructor overloading.

Explain Method Overriding.

When child class redefines its parent class method, it is called method overriding.

Method overriding is possible only between parent and child class methods.

For overriding, Name and Argument list of the parent and child class method should be the same.

Why Pointers is not used in Java?

Pointers take memory at the runtime to store the references so java don't use pointers to reduce memory consumption.

Also, by using pointers the particular memory area can be accessed directly, which can cause security issues.

What are OOPs?

OOPs are programming paradigms that rely on the concept of classes and objects. OOPs principles are:

  • Encapsulation

  • Inheritance

  • Polymorphism

  • Abstraction

Explain Inheritance and types of inheritance Java supports.

The process of acquiring the properties of an object, by another object is called inheritance. In other words, when an object of a class acquires the property of another class is called inheritance. Inheritance helps in reusing the code.

Extend keyword is used for inheriting.

Inheritance

Inheritance types

  • Single

  • Multilevel

  • Multiple(not supported by java through classes, but is supports through interfaces) 

  • Hierarchical

  • Hybrid(not supported by java if multiple inheritance is involved)

What is a garbage collector?

The garbage collector is a program that runs in the background at a time interval and tracks the objects in the memory that are not being used by any other part of the program. And when it finds any such object, it reclaims the space being used by that unreferenced object.

What is Autoboxing?

Automatic conversion of primitive types to their corresponding wrapper class objects is called autoboxing.

Can we convert wrapper class objects back to primitive types?

Yes, and this process is called unboxing.

These are some of the crucial questions asked in the interview. This is just a small part,Java is like an ocean. So if you are a beginner and want to learn java from basics to advance, you can head on to our youtube channel Learn Code With Durgesh

Share this article ...

💬WhatsApp📘Facebook💼LinkedIn🐦X

Trending Blogs...

The 5 ChatGPT Prompts That Saved Me From Burnout

The 5 ChatGPT Prompts That Saved Me From Burnout

Here’s what I discovered: It wasn’t about working less. It was about working smarter. When I gave ChatGPT the right prompts, everything changed. Here are the 5 prompts that transformed my productivity:

Mastering JavaScript: Functions, Objects, Classes & Prototypes Explained Like Never Before

Mastering JavaScript: Functions, Objects, Classes & Prototypes Explained Like Never Before

If you’re learning JavaScript, you’ve probably heard terms like functions, objects, classes, constructors, inheritance, and prototypes being thrown around. But what do they really mean? And why are they so important in JavaScript? In this blog, we’ll break down these concepts step by step, with clear explanations, examples, comparisons, and diagrams. By the end, you’ll have a solid understanding of how these features work together — and why they are the backbone of modern JavaScript.

Google Tools for College Students to boost Productivity

Google Tools for College Students to boost Productivity

College life can feel like a roller coaster — assignments, exams, group projects, internships, and of course, trying to squeeze in a social life. The good news? You don’t have to do it all alone. Google has built a whole ecosystem of tools that can help students stay productive, organized, and even a little more stress-free. From taking notes to collaborating on projects, Google’s apps are like a digital toolkit every student should know about. Let’s explore how these tools can make your college journey smoother.

Can AI Make Our Food Safer Than Ever?

Can AI Make Our Food Safer Than Ever?

Every year, millions of people around the world get sick from eating contaminated food. The World Health Organization (WHO) estimates that more than 600 million people fall ill annually, and about 4.2 million die from foodborne diseases. That’s a huge number — and the scary part is, much of it comes from something we can’t even see: toxic fungi known as mycotoxins. But now, scientists may have found a way to stop this problem before it even reaches our plates. Thanks to artificial intelligence (AI) and a powerful imaging technology, our food supply could soon become safer than ever.

What is Generative AI?

What is Generative AI?

Artificial Intelligence has gone from beating humans at chess to creating human-like poetry, realistic images, and even functional code. This creative side of AI is called Generative AI — and it’s one of the most exciting areas in modern technology. But to truly understand what Generative AI means, we need to take a quick trip through history, starting with an idea that shaped all of computer science: the Turing Machine.

The Evolution of AI - From Turing to Today

The Evolution of AI - From Turing to Today

Artificial Intelligence (AI) didn’t just appear out of thin air. The chatbot answering your questions today, the recommendation system suggesting your next Netflix binge, and the self-driving cars making headlines — all of these are the result of decades of innovation, setbacks, and breakthroughs. AI’s story is one of human curiosity: a mix of science fiction dreams, brilliant engineering, and a dash of “what if machines could think?” Let’s rewind the clock and see how it all began.

HTML the Easy Way-Unlock the web

HTML the Easy Way-Unlock the web

If you’ve ever wondered how websites are built, here’s the secret: almost every webpage you see starts with HTML. Whether it’s a simple blog post, an online shop, or a social media site – HTML is the foundation.

JUnit 5 and Mockito – From Scratch to Advanced

JUnit 5 and Mockito – From Scratch to Advanced

Learn JUnit 5 & Mockito from scratch to advanced with real-time Spring Boot examples. Covers unit & integration testing, annotations, MockMvc, H2 DB, and best practices.

Modern JavaScript for Developers in 2026

Modern JavaScript for Developers in 2026

Discover the modern JavaScript features developers should know in 2026 and learn how to future-proof your skills for the evolving web landscape. This in-depth guide covers JavaScript trends 2026, emerging frameworks, and best practices to help you stay ahead in web development. Explore the top JavaScript frameworks to watch in 2026, find out what’s new in modern JS features, and see how AI-assisted JavaScript development is shaping the future. Whether you’re updating your JavaScript developer roadmap 2026 or just getting started, this article will help you master the modern JavaScript tools and techniques needed to build fast, scalable, and future-ready applications.

Debouncing in JavaScript

Debouncing in JavaScript

In this article we will learn about the debouncing . We will learn about actual real problem and how to solve this problem using js debouncing.

Maven Tutorial

Maven Tutorial

Maven is a build automation tool primarily used for Java projects. It addresses two main aspects of building software: dependency management and project build lifecycle management.

Share this article ...

💬WhatsApp📘Facebook💼LinkedIn🐦X