Basic 18 Interviews Questions and Answers for Java Developers

  1. What do you understand by Java?

Java is an object-oriented computer language developed by James Gosling in Sun Microsystem in 1995. It is a secure, fast and reliable language used for many devices, games and applications.

  1. What do you mean by Object?

An object is a part of core java that consists of methods and classes which describe its state and perform operations. A java program encloses a lot of objects instructing each other their tasks.

  1. What is class in Java?

Java compresses the codes in several classes which describe new data types. These new data types are used to make objects.

  1. Define Inheritance.

Java consolidates the component of inheritance which an object-oriented programming concept. Inheritance lets a construed class to gain the techniques for a base class.

  1. Outline the major Java features.

Features:

  • Object-Oriented: It is based on object-oriented programming where the class and methods define the state and behavior of object.
  • Platform independent: java tackles on “write once and run anywhere” as it supports numerous platforms like Windows, Mac, Sun Solaris, Linux, etc.
  • Portable: Program in java gets converted into Java Byte Codes that can be performed on any platform without any dependency.
  • Interpreted: Java compiler converts the codes into Java Byte Codes which are then interpreted and executed by Java Interpreter.
  • Robust: As there is no pointer allocation, Java has a robust memory management. It has customized garbage collection that denies memory leaks.
  1. Differentiate between JDK, JRE and JVM.

JVM (Java Virtual Machine): It provides runtime environment for Java Byte Codes to be executed.

JRE (Java Runtime Environment): It includes sets of files required by JVM during runtime.

JDK (Java Development Kit): It consists of JRE along with the development tools essential to write and execute a program.

Java-training-QA

  1. Explain method overloading.

Right when a Java program contains more than one procedure with comparable name yet exceptional properties, by then it is called method overloading.

  1. Compare Overloading and Overriding.

Overloading: It is the case of having two methods of similar name but dissimilar properties.

Overriding: It is the case of having two methods of same name and properties, where one is in child class and other one is in parent class.

  1. Difference between the Inner Class and Sub Class

Inner Class: It is a class which is settled inside another class. It provides the access rights for the class which is settling it and that can get to all variables and procedures portrayed in the outer class.

Sub Class: It is a class which receives from another class called sub class. It provides access to all public and protected methods and fields of its super class.

  1. Can we execute any code in JAVA, even before the main method? Explain?

Yes, we can execute any code, even before the main method.

We are using a static square of code in the class while making the objects at stack time of class. Any statements inside this static bit of code will get executed one time while stacking the class, even before the making of objects in the main method.

  1. Define JSON?

JSON stands for JavaScript Object Notation is a much lighter and readable alternative to XML. It is an independent and easily parse-able in all programming languages. It is mainly used for Communicating between client – server or server -server communication.

  1. What are the advantages of JSON over XML?

The advantages of JSON over XML are:

  • JSON is Lighter and faster than XML
  • Easy to parse and conversion to objects for information consumption
  • Better understandable
  • Support various data types – JSON support string, array, number, Boolean but XML data are all strings
  1. Why Java doesn’t use pointers?

Pointers are inclined and slight inattentiveness in their use may result in memory problems and hence Java mainly manages their use.

  1. What’s the base class of all exception classes?

Java.Lang.throwable – It is the super class of all exception classes and all exception classes are derived from this base class.

  1. Are there any global variables in Java, which can be accessed by other part of your program?

Global variables are not permitted as it won’t fit well with the possibility of exemplification.

 

  1. When threads are not lightweight process in java?

Threads are lightweight process just if threads of same process are executing all the while. Regardless, if threads of different processes are executing all the while then threads are overpowering weight process.

  1. How can we create a Thread in Java?

There are two ways to create Thread in Java:

  • First by implementing Runnable interface and then creating a Thread object from it:
  • Second is to extend the Thread Class.
  1. Define Packages in Java?

A Package can be portrayed as a social occasion of related types (interfaces, classes, checks and remarks) giving access protection and name space management.

Top 24 Interviews Questions And Answers For Advanced Java Developers

Next
Previous

Add a Comment

Your email address will not be published. Required fields are marked *