Java Core Flashcards

1
Q

What is Java?

A

Java is a programming language developed under the concept of WORA (Write Once Run Anywhere). Java is statically typed and strong typed. Java is an object oriented programming language.

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

What it means for a language to be statically typed?

A

Statically typed programming languages do type checking (i.e. the process of verifying and enforcing the constraints of types) at compile-time as opposed to run-time. Dynamically typed programming languages do type checking at run-time as opposed to compile-time.

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

What it means for a language to be strongly typed?

A

A strongly-typed language is one in which variables are bound to specific data types, and will result in type errors if types do not match up as expected in the expression.

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

What is OOP?

A

Object-oriented programming (OOP) is a programming paradigm based on the concept of “objects”, which can contain data and code: data in the form of fields (often known as attributes or properties), and code, in the form of procedures (often known as methods).

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

What are the 4 pillars of OOP?

A

Abstraction, Polymorphism, Inheritance, Encapsulation

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

What is Abstraction?

A

Its main goal is to handle complexity by hiding unnecessary details from the user. That enables the user to implement more complex logic on top of the provided abstraction without understanding or even thinking about all the hidden complexity.

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

What is Polymorphism?

A

It describes the concept that objects of different types can be accessed through the same interface. Each type can provide its own, independent implementation of this interface.

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

What is Inheritance?

A

Inheritance can be defined as the process where one class acquires the properties (methods and fields) of another. … The class which inherits the properties of other is known as subclass (derived class, child class) and the class whose properties are inherited is known as superclass.

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

What is Encapsulation?

A

Encapsulation is defined as the wrapping up of data under a single unit. It is the mechanism that binds together code and the data it manipulates.Other way to think about encapsulation is, it is a protective shield that prevents the data from being accessed by the code outside this shield.

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

What is the Single Responsability Principle?

A

In programming, the Single Responsibility Principle states that every module or class should have responsibility over a single part of the functionality provided by the software.

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

What is the Open/Closed Principle?

A

In programming, the open/closed principle states that software entities (classes, modules, functions, etc.) should be open for extensions, but closed for modification.

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

What is the Liskov Substitution Principle?

A

it states that objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.

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

What is the Interface Segregation Principle?

A

The interface segregation principle states that no client should be forced to depend on methods it does not use.

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

What is the Dependency Inversion Principle?

A

This principle states that high-level modules should not depend on low-level modules. Both should depend on abstractions. And abstractions should not depend on details. Details should depend on abstractions.

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

What is a Thread?

A

A thread is an independent path of execution within a program.

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

How can you create Threads in Java?

A

Extending the Thread class or Implementing the Runnable Interface. In either case it is necessary to implement the run method. In order to initialize a Thread, the method start() must be invoked.

17
Q

What are the thread states?

A

New, Runnable, Blocked, Time-Waiting, Terminated

18
Q

What is a Java Bean?

A

A Bean is a class that implements Serializable, has a no-args Constructor, and has all its properties marked as private and have public getters and setters methods.

19
Q

What are the access modifiers in Java?

A

Public, Protected, Package Private (default), Private

20
Q

What are the non-access modifiers in Java?

A

Static, Final, Abstract, Synchronized, Transient

21
Q

What is static?

A

The static keyword is used to create variables that will exist independently of any instances created for the class. Only one copy of the static variable exists regardless of the number of instances of the class.

Static variables are also known as class variables. Local variables cannot be declared static.

22
Q

What is the final keyword in Java?

A

A final variable can be explicitly initialized only once. A reference variable declared final can never be reassigned to refer to an different object.

23
Q

What is Abstract?

A

An abstract class can never be instantiated. If a class is declared as abstract then the sole purpose is for the class to be extended.

24
Q

What is an iterator?

A

In computer programming, an iterator is an object that enables a programmer to traverse a container, particularly lists. Various types of iterators are often provided via a container’s interface.

25
Q

How is the Collection hierarchy?

A

Iterable Interface -> Collection Interface -> (List, Queue, Set) -> Concrete Classes