Questions and CORRECT Answers
What is an object? - CORRECT ANSWER - 1) Any entity that has state and behavior
2) An instance of a class
True/False: An object can be physical or logical - CORRECT ANSWER - True
What is a class? - CORRECT ANSWER - 1) In the context of JAVA:
Templates used to create objects and define object data types and methods
2) A blueprint from which you can create an individual object (e.g. blueprint for a skyscraper)
3) A group of objects that have common properties
Does Class consume any space? - CORRECT ANSWER - No
2 OOP advantages over Procedure Oriented Programming (POP) - CORRECT ANSWER -
1. Makes development and maintenance easier (POP is worse as project size increases)
2. Provides data hiding whereas POP can have its global variables accessed from anywhere
What is a constructor? - CORRECT ANSWER - 1) In JAVA:
Block of code called when an instance of an object is created, and memory allocated
, 2) Special type of method which is used to initialize an object
**
It is called "constructor" because it constructs the values at the time of object creation
**
Is a constructor required? - CORRECT ANSWER - No, JAVA would make a default
constructor
3 constructor rules - CORRECT ANSWER - 1) Constructor name must be the same as
class name
2) Constructor must have no explicit return type
3) A JAVA constructor cannot be abstract, static, final, or synchronized
2 types of constructors - CORRECT ANSWER - 1) Default constructor
2) Parameterized constructor
What is a default constructor? - CORRECT ANSWER - A default no-args constructor
**
1) It contains default call to super(); which is the default behavior
2) If you implement any constructor, default constructor will not be created