Java Flashcards

1
Q

Types of inheritance

A

Single
multilevel
hierarchical
hybrid
multiple(doesn’t support)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

jDK (java development kit)

A

It’s a package that includes the JRE, plus tools for developing, debugging, and monitoring Java applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

JRE (Java Runtime Environment):

A

It includes the JVM along with libraries and other components needed to run Java applications.

run a Java program on your computer, you need the JRE installed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

JVM (Java Virtual Machine)

A

JVM is a Java Virtual Machine which is a run time environment for the compiled java class files.

Converts bytecode to machine readable code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

JIT(Just-in-Time) Compiler

A

It is a part of JRE(Java Runtime
Environment), it is used for better performance of the Java applications
during run-time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Latest version of java

A

Java 22 & jDK 22

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Who developed Java ?

A

James Gosling at Sun Microsystems

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

when was java released?

A

May 1995

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Features of java

A

1.Platform independent
2.Simple and easy to learn
3.Object oriented
4.Robust and secure
5.Automatic Garbage Collection
6.High Performance
7.Multithreading

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

When was Jvm 1.0 released?

A

JDK 1.0 was released on January 23 1996.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Garbage collection

A

Garbage collection is the
automatic process of identifying
and reclaiming memory occupied
by objects that are no longer
referenced.
Java uses different
garbage collection algorithms like
generational, mark-and-sweep,
and G1.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Garbage value

A

The Garbage value isa random value at an address in the memory of a computer. It is leftover values from previous program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the Java Collections Framework, and why
is it important?

A

The Java Collections Framework provides a set of classes and interfaces
for working with collections of objects. It’s essential for efficient data
manipulation and storage in Java applications

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Difference between arrraylist and linklist

A

ArrayList is a dynamic array that allows fast random access, while
LinkedList is a doubly-linked list that is better suited for frequent insertions
and deletions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Explain the ‘finalize()’ method in Java.

A

‘finalize()’ is a method called by the garbage collector before an object is
reclaimed. It allows you to perform cleanup operations on resources like
files or sockets.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Describe the ‘enum’ type in Java and its
advantages.

A

An ‘enum’ is a special data type that defines a set of constant values. It
provides type safety, readability, and can be used in switch statements.

17
Q

What is the ‘autoboxing’ and ‘unboxing’ feature in
Java?

A

Autoboxing is the automatic conversion of a primitive type to its
corresponding wrapper class, and unboxing is the reverse process.

For example, converting ‘int’ to ‘Integer’ and vice versa.

18
Q

What are Java annotations, and how are they used?

A

Annotations provide metadata about the code and can be used to add
information to classes, methods, or variables. They are commonly used for
configuration, documentation, and code generation.

19
Q

What is an exception in java?

A

In java, an exception is an object. Exceptions are created when abnormal situations arise in our program.
Exceptions can be created by JVM or by our application code.

20
Q

Why doesn’t it support multiple inheritances?

A

Because of the “Diamond Problem”, Java doesn’t support multiple inheritances in classes.

21
Q

In how many ways we can do exception handling in java?

A

We can handle exceptions in either of the two ways :
1) By specifying a try-catch block where we can catch the exception.
2) Declaring a method with a throw clause.

22
Q

Why is Java not a pure object oriented language?

A

Java supports primitive data types - byte, boolean, char, short, int, float, long, and
double and hence it is not a pure object oriented language.

23
Q

How is Java different from C++?

A

C++ is only a compiled language, whereas Java is compiled as well as an
interpreted language.
Java programs are machine-independent whereas a c++ program can run only in
the machine in which it is compiled.
C++ allows users to use pointers in the program.
Whereas java doesn’t allow it.
Java internally uses pointers.

24
Q

Can you tell the difference between equals() method and
equality operator (==) in Java?

A

equals()
This is a method defined
in the Object class.
It is a binary operator in Java.
This method is used for
checking the equality of
contents between two
objects as per the
specified business logic.

==

This operator is used for
comparing addresses (or
references), i.e checks if both
the objects are pointing to the
same memory location.

It a binary operator in java

25
Q

Can the main method be Overloaded?

A

Yes, It is possible to overload the main method. We can create as many overloaded
main methods we want. However, JVM has a predefined calling method that JVM will
only call the main method with the definition of -
public static void main(string[] args)

26
Q

Difference between static methods, static variables, and
static classes in java??

A

Static Methods and Static variables are those methods and variables that
belong to the class of the java program, not to the object of the class. This gets
memory where the class is loaded. And these can directly be called with the help
of class names.