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.

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.

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.

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.

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

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.

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
  }
}

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;
    }
}

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.

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.

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