Program Principles Flashcards
What are the 4 programming principles?
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.
What is an interface?
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.
What is the ASCII value of A and a?
A = 65 a = 97
What is a static method? When to use it and why?
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.
What is singleton Pattern?
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.
What is a factory Pattern?
It is a pattern to hide instantiation logic to the client. Allows reference to created logic through a common interface.
2^5
32
2^10
1024
2^8
256
2^12
4096
2^32
4,294,967,296