top of page

History of JAVA

Java, modern object-oriented computer programming language. Java was created at Sun Microsystems, Inc., where James Gosling led a team of researchers in an effort to create a new language that would allow consumer electronic devices to communicate with each other. Work on the language began in 1991, and before long the team’s focus changed to a new niche, the World Wide Web. Java was first released in 1995, and Java’s ability to provide interactivity and multimedia showed that it was particularly well suited for the Web.
The difference between the way Java and other programming languages worked was revolutionary. Code in other languages is first translated by a compiler into instructions for a specific type of computer. The Java compiler instead turns code into something called Bytecode, which is then interpreted by software called the Java Runtime Environment (JRE), or the Java virtual machine. The JRE acts as a virtual computer that interprets Bytecode and translates it for the host computer. Because of this, Java code can be written the same way for many platforms (“write once, run anywhere”), which helped lead to its popularity for use on the Internet, where many different types of computers may retrieve the same Web page.

Questions

Q1. Explain JVM, JRE, and JDK.

JVM (Java Virtual Machine): JVM(Java Virtual Machine) acts as a run-time engine to run Java applications. JVM is the one that calls the main method present in Java code. JVM is a part of JRE(Java Runtime Environment).
JRE (Java Runtime Environment): JRE refers to a runtime environment in which Java bytecode can be executed. It implements the JVM (Java Virtual Machine) and provides all the class libraries and other support files that JVM uses at runtime. So JRE is a software package that contains what is required to run a Java program.
It’s an implementation of the JVM which physically exists. JDK(Java Development Kit): It is the tool necessary to compile, document, and package Java programs. The JDK completely includes JRE which contains tools for Java programmers.
The Java Development Kit is provided free of charge. Along with JRE, it includes an interpreter/loader, a compiler (javac), an archiver (jar), a documentation generator (Javadoc), and other tools needed in Java development. In short, it contains JRE + development tools.

Q2. Explain public static void main(String args[]).

Public: Public is an access modifier.
Public means that this Method will be accessible by any Class.

static: It is a keyword in java that identifies it as class-based i.e it can be accessed without creating the instance of a Class.
Since we want the main method to be executed without any instance also, we use static.

Void: It is the return type of the method.
Void defines the method which will not return any value.

main: This is the first method executed by JVM.
The signature of the method must be the same.

Q3. Why Java is platform independent?

Platform independence practically means “write once run anywhere”. Java is called so because of its byte codes which can run on any system irrespective of its underlying operating system.

Q4. Why is Java not purely Object-oriented?

Java is not considered pure Object-oriented because it supports primitive data types such as boolean, byte, char, int, float, double, long, and short.

Q5. Define class and object. Explain them with an example using java.

Class: A class is a user-defined blueprint or prototype from which objects are created. It represents the set of properties or methods that are common to all objects of one type.
In general, class declarations can include these components, in order:
Superclass(if any): The name of the class’s parent (superclass), if any, preceded by the keyword extends. A class can only extend (subclass) one parent.
Interfaces: A comma-separated list of interfaces implemented by the class, if any, preceded by the keyword implements. A class can implement more than one interface.
Object: It is a basic unit of Object Oriented Programming and represents real-life entities. A typical Java program creates many objects, which as you know, interact by invoking methods. An object consists of :
State: It is represented by attributes of an object. It also reflects the properties of an object.
Behavior: It is represented by the methods of an object. It also reflects the response of an object to other objects.
Identity: It gives a unique name to an object and enables one object to interact with other objects.

Q6. What is a method? Provide several signatures of the methods.

A Java method is a set of statements to perform a task. A method is placed in a class. Signatures of methods: The method’s name, return type, and the number of parameters comprises the method signature. A method can have the following elements in its signature: – Access specifier – public, private, protected, etc. (Not mandatory)
– Access modifier – static, synchronized, etc. (Not mandatory)
– Return type – void, int, String, etc. (Mandatory)
– Method name – show() (Mandatory)
– With or without parameters – (int number, String name); (parenthesis are mandatory)

Q7. Explain the difference between an instance variable and a class variable.

An instance variable is a variable that has one copy per object/instance. That means every object will have one copy of it. A class variable is a variable that has one copy per class. The class variables will not have a copy in the object.

Example:
class Employee {
int empNo;
String empName, department;
double salary;
static int officePhone;
}
An object referred to by empObj1 is created by using the following:
Employee empObj1 = new Employee();

The objects referred by instance variables empObj1 and empObj2 have separate copies empNo, empName, department, and salary. However, the officePhone belongs to the class(Class Variable) and can be accessed as Employee.officePhone.

Q8. Which class is the superclass of all classes?

java.lang.Object is the root class for all the java classes and we don’t need to extend it.

Q9. What are constructors in Java?

In Java, a constructor refers to a block of code that is used to initialize an object. It must have the same name as that of the class. Also, it has no return type and is automatically called when an object is created.
If a class does not explicitly declare any, the Java compiler automatically provides a no-argument constructor, also called the default constructor.
This default constructor calls the class parent’s no-argument constructor (as it contains only one statement i.e. super();), or the Object class constructor if the class has no other parent (as the Object class is a parent of all classes either directly or indirectly).

There are two types of constructors:

1. Default constructor
2. Parameterized constructor

Q10. What are the different ways to create objects in Java?

1There are many different ways to create objects in Java.

1. Using new keyword
2. Using new instance
3. Using clone() method
4. Using deserialization
5. Using newInstance() method of Constructor class

Who We Are

Job Connect is a platform that connects job seekers with potential employers. We offer a wide range of job opportunities in various industries and locations, making it easier for job seekers to find suitable employment.We at Job Connect narrow down job seekers' search criteria based on factors such as job type, location, salary, and experience level. Additionally, we also offer career advice to help job seekers with their job search and Interview preparation to get set go for their carrer path.

bottom of page