OOP Midterm Exam

0.0(0)
studied byStudied by 3 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/232

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

233 Terms

1
New cards

Classification

is the process of grouping objects together based on common characteristics.

In Java, this is achieved through the use of classes and interfaces.

2
New cards

Classes, interfaces

_____ and _____ can be used to classify objects based on their attributes and behaviors.

3
New cards

Interface

is a collection of abstract methods and constants that can be implemented by a class

4
New cards

Interface

defines a set of methods that a class implementing that interface must provide.

5
New cards

methods in an interface

do not have any implementation, but only the method signatures are defined.

6
New cards

inheritance

Hierarchical relationship of classesi is created using _____.

7
New cards

child class

can inherit properties and methods from a parent class, and can also add its own properties and methods.

8
New cards

hierarchy of classes

This creates a _____, where each child class can inherit from its parent class, and can also be inherited by other child classes.

9
New cards

Generalization

is the process of creating a more general class from a more specific class.

10
New cards

Generalization

This allows you to create a hierarchy of classes that share common properties and behavior.

11
New cards

Specialization

is the opposite of generalization

12
New cards

Specialization

it involves creating a more specific class from a more general class.

13
New cards

Specialization

This allows you to add additional properties and behavior to a more specific class without affecting the more general class.

14
New cards

Specialization

is the act of capturing differences among objects in a class and creating new distinct subclasses with the differences.

15
New cards

Specialization

In this way, we are specializing information about objects of the superclass into subclasses.

16
New cards

Classification

categorizing objects into a class.

17
New cards

Classification

A subclass is a specialized class of a superclass, and a superclass is a generalized class of a subclass.

18
New cards

Generalization

the act of capturing similarities between classes and defining the similarities in a new generalized class

19
New cards

Generalization

the classes then become subclasses of the generalized class.

20
New cards

Specialization

the act of capturing differences among objects in a class and creating new distinct subclasses with the differences.

21
New cards

message

is a method call from a message-sending object to a message-receiving object.

22
New cards

message-sending object

is a sender

23
New cards

message-receiving object

is a receiver.

24
New cards

object

  • responds to a message by executing one of its methods.

  • may have as many methods as required

25
New cards

arguments

Additional information, known as _____, may accompany a method call.

26
New cards

parameterization

Such _____ allows for added flexibility in message passing

27
New cards

set of methods

collectively defines the dynamic behavior of an object.

28
New cards

object identifier, method name, arguments

A message is composed of three components

29
New cards

object identifier

indicates the message receiver

30
New cards

method name

corresponding to a method of the receiver

31
New cards

Arguments

additional information required for the execution of the method

32
New cards

method

is a program module that contains a series of statements that carry out a task.

33
New cards

main() method

can execute additional methods, and those methods can execute others.

34
New cards

class

Any _____ can contain an unlimited number of methods, and each method can be called an unlimited number of times.

35
New cards

calling method or client method

invokes a called method.

36
New cards

public,

private,

protected,

default

4 access modifiers

37
New cards

Return type

is a method that returns a value of a specific type after performing some operation.

38
New cards

return type of the method

specifies the type of the value that the method returns.

39
New cards

method that does not have a return type

is a method that does not return a value

40
New cards

method that does not have a return type

These methods are typically used to perform some operation or modify the state of an object, but they do not return any value.

41
New cards

void

The return type of a method that does not return a value is specified as _____

42
New cards

return statement

A method ends when any of the following events takes place:

The method reaches a _____.

43
New cards

return statement

causes a method to end and the program’s logic to return to the calling method.

44
New cards

return statement

frequently sends a value back to the calling method.

45
New cards

method’s return type

is known more succinctly as a method’s type.

46
New cards

Method chaining

Any method might call any number of other methods.

47
New cards

Client

Refers to an object that requests some operation to be performed by another object.

48
New cards

Client

The _____sends a message (invokes a method) to another object, asking it to perform a specific task or provide some information.

49
New cards

Client

is typically responsible for making the initial request and for processing any results that are returned.

50
New cards

Server

Refers to the object that receives and processes the message sent by a client.

51
New cards

Server

contains the methods that can be invoked by clients.

These methods define the behavior of the _____ object.

52
New cards

Server

After receiving a message, the _____ object performs the necessary operations and may return a result to the client.

53
New cards

Method overloading

in Java is a feature that allows a class to have multiple methods with the same name but different parameters.

54
New cards

Method overloading

This is useful when you want to perform the same operation with different types of data or with different numbers of arguments.

55
New cards

Method overloading

The compiler chooses the correct method to call based on the arguments that are passed.

56
New cards

parameter identifiers

do not have to be different, but the parameter lists must satisfy one or both conditions

57
New cards

different numbers

The lists must have _____ of parameters.

58
New cards

parameter data types

The lists must have _____ in different orders

59
New cards

Constructor overloading

in Java is a feature that allows a class to have multiple constructors with the same name but different parameter lists.

60
New cards

Constructor overloading

This is useful when you want to create objects with different sets of initial values or with different ways of initializing the object's state.

61
New cards

Constructor overloading

The compiler chooses the correct constructor to call based on the arguments that are passed.

62
New cards

Reference

is a type of variable that stores a memory address, which is the location of an object in the computer's memory.

63
New cards

reference

When you create an object in Java, the JVM allocates memory for the object and returns a _____ to that memory location.

64
New cards

reference variable

can be used to access the data and methods of the object it refers to.

65
New cards

reference

When you pass a ____ to a method, the method can modify the state of the object, and the changes are visible outside the method.

66
New cards

constant field

is a variable whose value cannot be changed after it is initialized.

67
New cards

constant field

are commonly used for values that are known at compile-time and should not be modified during runtime.

68
New cards

final keyword

is used to declare a variable, method, or class that cannot be changed or overridden after it is initialized.

69
New cards

is-a relationship

is used to describe inheritance and class hierarchies.

70
New cards

is-a relationship

It represents a relationship between a more general, abstract class (superclass or base class) and a more specific, concrete class (subclass or derived class).

71
New cards

Creating objects by instantiating those classes.

Developing classes to run as standalone applications.

Object-oriented programming involves creating classes, which can serve two main purposes:

72
New cards

application class

is identified by having a public static void main(String[] args) method

73
New cards

public static void main(String[] args) method

serves as the entry point for the application

74
New cards

Classes that lack main() method

are typically meant to be used by other classes that serve as applications, promoting code modularity and reusability.

75
New cards

main() method

a Java application can only have one _____ with the specific header public static void main(String[] args).

76
New cards

Creating a Class

Assign name to class

Determine what data and methods will be part of class

Class header

  • Optional access modifier

  • Keyword class

  • Any legal identifier for the name of class

    • Uppercase camel casing (conventional identifier)

77
New cards

Uppercase camel

Any legal identifier for the name of class

_____ casing (conventional identifier)

78
New cards

Creating a Class

In Class Body

  • Declaring instance

    • Attributes represent Variable

    • Declaring variable inside a class called Instance variable

79
New cards

Instance variable

Declaring variable inside a class called _____

80
New cards

static field

Shared among all instances of the class.

81
New cards

static field

only one copy, and it is shared by all objects of the class.

82
New cards

nonstatic field

Belong to individual instances (objects) of the class.

83
New cards

nonstatic field

Each object has its own set of this

84
New cards

private field

provide highest level of security to a field means that no other classes can access the field’s values, and only methods of the same class are allowed to set, get, or otherwise use private variables.

85
New cards

information hiding

  • principle used in creating private access is sometimes called _____;

  • is an important component of object-oriented programs.

86
New cards

Instance methods

in Java are methods that belong to an instance of a class, rather than to the class itself.

87
New cards

Instance methods

They are defined within a class, and can access and modify the state of the instance variables of that class

88
New cards

Static method

can call a static method on the class itself, without creating an object of that class.

89
New cards

nonstatic method

access and modify instance-specific data and variables, and their behavior can vary from one object to another.

90
New cards

Access Modifier

Return type

Method name

Parameter

4 Components of creating instance method

91
New cards

Method Body

It is a part of the method declaration.

92
New cards

Method Body

It contains all the actions to be performed.

93
New cards

Method Body

It is enclosed within the pair of curly braces.

94
New cards

Mutator method,

Accessor method

2 Types of Instance Method

95
New cards

Mutator method

is a type of instance method that is used to set or modify the value of an object's instance variable.

96
New cards

Mutator method

It is also known as a "setter" method because it "sets" a new value for a variable.

97
New cards

Accessor method

is a type of instance method that is used to get the value of an object's instance variable.

98
New cards

Accessor method

It is also known as a "getter" method because it "gets" the current value of a variable.

99
New cards

Mutator method

Define the method within the class definition.

Specify the access modifier (public, private, or protected) and any other relevant modifiers.

Specify the return type of the method. It is usually void because it doesn't return anything.

Specify the method name, using a naming convention like setVariableName() to indicate that it is a ____ method.

Write the code for the method inside curly braces to set the new value for the variable.

100
New cards

Accessor method

Define the method within the class definition.

Specify the access modifier (public, private, or protected) and any other relevant modifiers.

Specify the return type of the method to match the data type of the variable you want to retrieve.

Specify the method name, using a naming convention like getVariableName() to indicate that it is an _____ method.

Write the code for the method inside curly braces to return the value of the variable.