02 Prelim CP2 Flashcards
A type of paradigm in which programmers can define key programmkng concepts (such as data structures and the types of operations that can be applied to them.)
Object-Oriented Programming (OOP)
In object oriented programming, each object has 3 dimensions:
- Identity
- Attributes
- Behavior
A (1)_______ ___ in (2)_____ and other programming languages intends to make (3)______ about programming (4)______ to the (5)_____ world.
- Programming style
- Java
- Thinking
- Closer
- Real
In OOP, each object is an (1)_______ ____ with a (2)_____ identity, just as objects in the (3)_____ world are. This allow program objects to properly (4)______ their real-world (5)_________.
Ex. An apple is an object, so is a mug. Each has its unique identity.
- Independent unit
- Unique
- Real
- Represent
- Counterparts
Objects also have (1)______, which are used to (2)______ them.
Ex.
A car can be red or blue, a mug can be full or empty, and so on.
These (1)_______ are also called (3)________.
- Characteristics
- Describe
- Attributes
An attribute describes the current (1)______ of an object.
In the real world, each object behave in its osn way; a car can move, a phone can ring or vibrate, and so on.
The same applies to (2)______ objects, as (3)_______ is specific to the object’s type.
- State
- Program
- Behavior
- A group or collection of OBJECTS having similar or common properties
- each _______ has a name, and each is used to define attributes and behavior.
Ex.
Attributes
- name
- weight
- age
Behavior
- walk
- run
- sleep
Class or classes
A (1)______ describes what an object derived from it will be, but is a completely separate (2)______ from the (3)_______ itself. In other words, (4)______ can be described as (5)_______, (6)_________, or (7)_______ for an object.
- Class
- Entity
- Object
- Classes
- Blueprints
- Descriptions
- Definition
(1)_______ is a collection of (2)______ that are group together to perform an (3)________.
An example of (1)_________ is the:
(4)_______________
(1)______ define (5)______
You can (6)______ your own (1)______ to perform your desired task
- Method
- Statements
- Operation
- System.out println() method
- Behavior
- Define
What is the method in this program:
class MyClass {
static void sayHello() {
system.out.println(“Hello World!”);
}
public static void main (String [] args) {
sayHello();
}
}
// output: Hello World!
static void sayHello() {
system.out.println(“Hello World!”);
}
- (1)________ a method can be done as many times as (2)_______.
- When method runs, the code (3)______ to where the method is (4)_____, executes the (5)_____ inside of it, then goes (6)______ and proceed to the (7)______ line.
- Calling
- Necessary
- Jumps
- Defined
- Inside
- Back
- Next
(1) ______ _______
- You can also create a method that takes some data, called (2)_____, along with it when you call it.
- Parameters can be written within the method’s (3)_________
For example, we can modify our sayHello() method to take and output a String parameter:
The method in the example takes a String called name as a parameter, which is used in the method’s body. Then, when calling the method, we pass the parameter’s value inside the (3)_____.
- Methods can take (4)_______ parameters, each separated by a (5)________.
- Method parameters
- Parameters
- parentheses (( ))
- Multiple
- Comma (,)
Advantages of using methods instead of simple statements in Java programing:
- Code reuse
- Parameter passing
You can write a method once, and use it multiple times on multiple classes without having to rewrite the code each time on each
class.
Code reuse
Based on the parameters passed in, methods can perform various actions.
Parameter passing