Learn Code With Durgesh LogoLCWD
HomeCoursesBlogsContact Us
HomeCoursesBlogsContact Us
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

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 durgesh • 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...

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.

Important DSA Topics for placements

Important DSA Topics for placements

Data Structures and Algorithms (DSA) are fundamental building blocks of computer science. A strong understanding of DSA is essential for every developer, regardless of their specialization.

Amazing Windows key shortcuts in Windows 11

Amazing Windows key shortcuts in Windows 11

Shortcuts are everyone’s favorite, be it in life or in Keyboard. We don’t know about life but we have some amazing shortcut tricks for your keyboard, which are newly introduced in windows 11. Let's have a look and understand these amazing shortcuts to reduce our finger pain

Share this article ...

💬WhatsApp📘Facebook💼LinkedIn🐦X