How well do you know Java?

·

3 min read

How well do you know Java?

The following questions will help you get familiar with Java programming language terms.

Explain JDK, JRE, and JVM?

JDK - Java Development Kit Is a software development environment used for developing Java applications and applets. This is inclusive of Java Runtime Environment (JRE), an interpreter/loader, a compiler, an archiver(jar), a documentation generator, and other tools needed in Java development.

JRE - Java Runtime Environment Is the on-disk program that loads Java applications for the JVM to execute.

JVM - Java Virtual Machine Enables a computer to run Java programs as well as other programs written in other languages that are also compiled to Java bytecode.

Explain public static void main(String args[]) in Java

Class main {
  Public static void main(String[] args) {
    //Write your code here
  }
}

public - it is the access specifier. From anywhere we can access it.

static - it is the access modifier when we can call the methods directly without creating objects.

void - it is the return type.

main - it is the method name.

Why Java is platform-independent?

Java is platform-independent because it does not depend on any type of platform. In Java, programs are compiled into byte code and that byte code is platform-independent.

Why Java is not 100% Object-oriented?

JAVA supports primitive data type as it, byte, long, etc. In Java, we use data types like int, float, double, etc which are not object-oriented

What are wrapper classes in Java?

Is a class that encapsulates types, so that those types can be used to create object instances and methods in another class that needs those types.

What are constructors in Java?

A constructor in Java is similar to a method that is invoked when an object of the class is created. Unlike Java methods, a constructor has the same name as that of the class and does not have any return type.

For example,

class JadenCase{
  JadenCase() {
    // constructor body
  }
}

What is a singleton class in Java and how can we make a class singleton?

Is a class that can have only one object (an instance of the class) at a time. After first time, if we try to instantiate the Singleton class, the new variable also points to the first instance created.

public class SingletonClass {
    private static final SingletonClass SINGLE_INSTANCE = new SingletonClass();
    private SingletonClass() {}
  public static SingletonClass getInstance() {
      return SINGLE_INSTANCE;
    }
}

What is the difference between Array list and vector in Java?

ArrayList increments 50% of the current array size if the number of elements exceeds its capacity while Vector increments 100% means double the array size if the total number of elements exceeds its capacity.

Vector's methods are synchronized and ArrayList's methods are not synchronized.

What is the difference between equals() and == in Java?

equals() method for content comparison. In simple words, == checks if both objects point to the same memory location whereas. equals() evaluates to the comparison of values in the objects.

What are the differences between Heap and Stack Memory in Java?

The Heap Space contains all objects that are created, but Stack contains any reference to those objects. Objects stored in the Heap can be accessed throughout the application.

That's it. Thanks for reading my article.

Buy me a cup of coffee