Java Core which is an edition of Java also known as Java SE (Standard Edition). The core java is the basic Java and in interviews, most of the questions for a java developer comes from here. Here in this article we have mentioned the frequent questions ever asked in the Java Interview. With the increment in the flow of interview questions, difficulty raise too.
Core Java Interview Questions
Question: What is Java?
Answer: Java is a general-purpose high-level, object-oriented programming language which works on a principle “write once and run anywhere”. It was developed by James Gosling in 1991 at Sun Microsystems later one bought by Oracle Corporation.
Question: What is Core Java?
Answer: When Oracle bought Java, they give their own definition to it and release a Java Standard Edition which commonly known as Java. The core Java deals with the basic type and Object of Java Programming.
Question: What is the Java language programming platform?
Answer: Java is a programming language and a platform too. A Java platform is an environment for Java programming language on which its application runs.
Question: Name all Java Programming language platforms.
- Java Platform Standard Edition
- Java Platform, Enterprise Edition
- Java Platform, Micro Edition
Question: What are the components that a Java Platform consist?
Answer: All Java platforms have two components Java Virtual Machine (VM) and Application Programming Interface (API).
Question: What is Java Virtual Machine?
Answer: It is a program that is designed for specific hardware and software platform so it could run the application based on Java Technology.
Question: What is an API?
Answer: API stands for Application Programming Interface which is a software component collection, that a Java developer uses to develop other software components and applications.
Question: What is Java EE?
Answer: Java EE where EE stands for Java Enterprise Edition which is also known as Advance Java, this Java platform is made up on Java Standard Edition platform. This platform is mainly used to create enterprise level application because this provides an API and runtime environment for developing and running large-scale application.
Question: What is Java ME?
Answer: Java ME or Micro Edition, this platform of Java is used to create micro native applications for small devices like Mobile Phones. This platform uses Java Standard Edition API and libraries to develop applications.
Question: What is JavaFX?
Answer: This Java platform is used to build and develop Internet-based applications which use lightweight API.
Question: Give some feature of Core Java.
- It is simple basically it follows the similar syntax based on C++ language
- It is an Object-oriented programming platform, which follows all the concepts of OOP’s.
- It is platform independent.
- It provides security as compared to other programming languages
- It has a strong Memory management
- The provides high-quality application development
- It supports multithreaded which mean it can handle many tasks at once.
Question: Name all the OOP’s concepts present in Java.
Question: Is Java a pure object-oriented programming language?
Answer: No, Java is not a pure object-oriented programming language because it has primitive data types which are not objects and to be a pure object-oriented programming language everything should be an object in the programming language.
Question: Is Java Virtual machine platform independent?
Answer: No, it is not that’s why we have different JVM for different platforms.
Question: What is abstraction?
Answer: Abstraction is a process of hiding the main source from the user and only show the functionality it is the common practice of each object-oriented programming language.
Question: What is the difference between JVM and JRE?
Answer: Java Runtime Environment (JRE) is a collection of JVM and java binaries, basically, JRE is the implementation of Java Virtual Machine.
Question: What is a Classloader?
Answer: A Java Classloader is an inbuilt program in JDK which is used to load the byte code program into memory when a program accesses any class.
Question: Name all the different types of Classloader in Java.
- Bootstrap Classloader
- Extension Classloader
- System Classloader
Question: What is a class in Java?
Answer: Everything we code in Java we code it inside a class block, here class is a blueprint of an object and a collection of different attributes and methods.
Question: What is a constructor?
Answer: A constructor is a method in the class which share the same name as the class, and it gets invoked automatically at the moment the object of that class gets created. Basically, the constructor of a class is used to initialize values to the variables.
Question: Name all the types of the constructor we used in JAVA?
Answer: In Java constructor are of two types:
- Default constructor
- Parameterized constructor
Question: What is an Object?
Answer: When we create an instance of the class is known as its object. Basically, at the moment we create the instance or object of a class that class comes in existence and with the help of that object or instance we could access the class attributes and methods.
Question: What is inheritance?
Answer: Inheritance is one of the important OOP’s concepts which used to increase the code reusability in a programming language. With the help of inheritance, we can use the properties of one class in another class.
Question: What is the Java superclass for all classes?
Answer: java.lang.object is the root class for all Java classes.
Question: What is Method Overriding?
Answer: In method overriding the sub-class and superclass shear the same method name, and arguments.
Question: What is Method Overloading?
Answer: When more than one method of a class shear the same name with different arguments is known as method overloading.
Question: What is an interface in Java?
Answer: Java in-built does not support multiple inheritances so in order to overcome this problem we use interface concept in java.
Question: Name all the types of Memory are allocated by Java Virtual Machine.
- Class (Method) Area
- Program counter Register
- Native Method Stack
Question: What is JIT compiler?
Answer: JIT Just-in-Time compiler is a part of JRE Java Runtime Environment, and it optimizes the performance of Java-based application at run time.
Question: What makes Java code write once and run anywhere?
Answer: Though Java source code could not run anywhere but, when the code gets compiled it gets converted into byte code (class file), which is a middle code format between source code and machine code and this byte code is platform independent.
Question: What is an abstract class in Java?
Answer: In Java, we can create an Abstract class using ‘abstract’ keyword before the class name. And an abstract class should have at least one abstract method.
Question: What is an abstract method?
Answer: An abstract method is a special method in the abstract class which have the only implantation and does not contain any body declaration.
Question: Does Java have virtual functions?
Answer: Yes, apparently all the Java methods are virtual by default.
Question: What are public and private access modifiers?
The class members under the public access modifier can be accessed by another class which inherit it.
Class members under the private access modifier are not visible outside the class and even the subclass cannot inherit the private access modifiers members.
Question: Does Java provide default values for the local variables?
Answer: No, the coder has to initialize the value explicitly.
Question: Name all the access modifier used in Java.
Question: What are the static methods and variables?
Answer: To make any variable and method static we use the static keyword and when we make any variable static the value of that variable remains same for all the methods of the class, its like that we have fixed that variable value. We commonly use static methods and variable for those classes in which we want, all its objects of share the common variable and method.
Question: What is the difference between an object-oriented programming language and object-based programming language?
Answer: The Object-oriented programming language support the OOP’s concept like Inheritance, polymorphism etc, whereas the object-based programming language does not have OOP’s concept
In Object-Oriented programming, language object are not pre-defined but in Object-based programming language objects are pre-defined
Question: Why the main method is static?
Answer: We do not need an object to call a static method. Though we could make the main() method non-static, here JVM have to create an object to call the main() method that leads to extra memory allocation.
Question: What does this keyword do in Java?
Answer: The keyword this is used to refer the current of the object of the class it can also refer to the current properties of the class such as instances, method, variables and constructor. The use of this keyword comes very handy when we create trees algorithm and program, it used to separate the parent class from the child class.
Question: Can this keyword refer to the static method?
Answer: Yes, it can but it does not make any difference because the static value remains the same for all the objects.
Question: What are pointers and does Java has pointers?
Answer: A pointer is a user-defined variable which is used to point the memory address of another variable and Java does not pointers.
Question: What is a garbage collector?
Answer: In Java, the interpreter takes care of the memory allocation and deallocation of objects at heap memory. When an object is of no use the interpreter deallocates the object with the help of garbage collector.
Question: What are the exceptions?
Answer: An exception is an unwanted error occur during the execution of a program. Exception normally occurs during the runtime, and to counter these exceptions we use exception handling.
Question: What is Serialization?
Answer: When a file is get converted into byte stream is known as serialization, the serialization is done for the security purpose.
Question: Where does the volatile variable stores?
Answer: In the main memory
Question: What is a final variable in Java?
Answer: Final variables are those variables that once get assigned couldn’t be updated by the user. If there is a final variable which is not assigned yet so the user can only assign it with the help of class constructor.
Question: What do you mean by final class?
Answer: Once we declare a class final it could not be inherited by any other class.
Question: What is dynamic polymorphism?
Answer: A dynamic polymorphism or runtime polymorphism is a process to call the overridden methods at the runtime instead of compile time.
Question: What is the difference between static binding and dynamic binding?
Answer: In static binding, the object binds with the method at compile time but in dynamic binding, the object binds with methods at runtime.
In the above article, we have provided top 50 Core Java interview questions and the core Java is also known as basic Java. Most of the question in the above article based on the OOP’s concepts because that’s what Java is famous for.