Program Principles Flashcards

1
Q

What are the 4 programming principles?

A

Encapsulation: Restrict the access of members from outside.
Abstraction: To simplify program for user interface. Only provide high level operations.
Inheritance: Ability to give sub classes members from parents to share data members and implement unique members/functions.
Polymorphism: To modify functions to provide unique implementation for subclass.

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

What is an interface?

A

Interface is a means to do abstraction. An interface itself, does not implement any methods. It provides method prototypes while the classes implementing the interface will define it. An interface implies that the methods it has will be abstract and public.

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

What is the ASCII value of A and a?

A
A = 65
a = 97
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a static method? When to use it and why?

A

A static method is a method that does not require any instantiation. You should use a static method if you are not using a variable that is instantiated or you are not modifying the state of an object.

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

What is singleton Pattern?

A
This pattern ensures that there exists only one instance of an object in the JVM. Singleton class must have a global access point to get to the instance. 
Applications: Logger: Can track logging operations without instancing an object everytime.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a factory Pattern?

A

It is a pattern to hide instantiation logic to the client. Allows reference to created logic through a common interface.

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

2^5

A

32

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

2^10

A

1024

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

2^8

A

256

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

2^12

A

4096

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

2^32

A

4,294,967,296

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