Java Flashcards

1
Q

What is a JVM?

A

JVM (Java Virtual Machine) is an abstract machine. It provides runtime environment in which java bytecode can be executed.

The JVM performs following operation:

  • Loads code
  • Verifies code
  • Executes code
  • Provides runtime environment

JVM provides definitions for the:

  • Memory area
  • Class file format
  • Register set
  • Garbage-collected heap
  • Fatal error reporting etc.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Object Oriented Programming?

A

The object-oriented programming is basically a computer programming design philosophy or methodology that organizes/ models software design around data, or objects rather than functions and logic.

An object is referred to as a data field that has unique attributes and behavior. Everything in OOP is grouped as self-sustainable objects.

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

What are the four pillars of OOP?

A
  • Abstraction
  • Encapsulation
  • Inheritance
  • Polymorphism
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does abstraction mean and why it’s useful?

A

Abstraction allows us to hide the implementation of a function from the interface. This process is called “abstraction” in OOP, because we are abstracting away the gory implementation details of a class and only presenting a clean and easy-to-use interface via the class’ member functions.

It’s useful because this separation:

  • helps isolate the impact of changes
  • reduces complexity (you don’t need to understand the implementation, only the interface)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does Encapsulation mean?

A

In OOP, we encapsulate by binding the data and functions which operate on that data into a single unit, the class. By doing so, we can hide private details of a class from the outside world and only expose functionality that is important for interfacing with it.

Encapsulation protects data and functions from outside interference and misuse. Therefore, it also provides security.

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

What does Inheritance mean?

A

The concept allows us to inherit or acquire the properties of an existing class (parent class) into a newly created class (child class). It is known as inheritance. It provides code reusability.

Programmers applying the technique of inheritance arrange these classes into what is called an “IS-A” type of relationship.

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

What does Polymorphism mean?

A

Polymorphism means “many forms”, and it occurs when we have many classes that are related to each other by inheritance.

Therefore, calling code only needs to be written to handle objects from the root of the hierarchy, and any object instantiated by any child class in the hierarchy will be handled in the same way.

e.g.:
we have an Animal class (parent) and Pig, Dog and Cat classes (child). Pig, Dog and Cat extends the Animal class. In this case you can do this:
Animal myAnimal = new Animal(); 
Animal myPig = new Pig(); 
Animal myDog = new Dog();

This is polymorphism.

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