05 - Program Development Flashcards
Define the term ‘class’ in Object Oriented Programming.
A class can be defined as a template/blueprint that describes the object of its type.
What is an identifier?
An identifier is a pointer that explicitly defines an object, class interface, method, or variable.
What are the three types of variables in Java?
1) Instance Variable: Declared inside a class but outside any method. It belongs to an instance (object) of the class and stores object-specific data.
Example: String name;
2) Parameter Variable: Declared inside a method’s parentheses. It stores values passed to the method when it is called.
Example: public void greet(String name)
3) Local Variable: Declared inside a method or block. It is accessible only within that method/block and is created and destroyed when the method/block runs.
Example: int sum = 5 + 3;
What is an instance variable?
A variable in a class from which every instantiated object gets its own copy.
What is a parameter variable?
A variable that is passed along to a function to perform operations.
What is a local variable?
A variable declared inside a function, known and only accessible by that function.
Define the term ‘method’ in Java.
A Java method is a collection of statements that are grouped together to perform an action.
What is an accessor method?
An accessor method is used to return the value of a private field, prefixed with ‘get’.
What is a mutator method?
A mutator method is used to set a value of a private field, prefixed with ‘set’.
What is a constructor in Java?
A constructor is the method that is called when an object is instantiated.
What is a method signature?
A method signature is a combination of the method name and the parameter list.
What does the private modifier specify?
The member can only be accessed in its own class.
What does the protected modifier specify?
A member can only be accessed within its own class/package and by a subclass.
What does the public modifier do?
A class declared with public is visible to all classes everywhere.
What is inheritance in programming?
Inheritance is the process where one object acquires the properties of another.