OOP flashcards

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

1/70

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.

71 Terms

1
New cards

What is the primary purpose of data abstraction in object-oriented programming?

To hide certain implementation details from the user and only show essential information.

2
New cards

Can an object be created directly from an abstract class?

"No

3
New cards

Where must the body of an abstract method be provided?

The body of an abstract method must be provided by the subclass that inherits from the abstract class.

4
New cards

What kind of class is described as a 'completely abstract class' used to group related methods?

An interface.

5
New cards

"If a class in Java implements an interface but does not provide implementations for all its methods

what must be done?"

6
New cards

What is the syntax for an enhanced for-loop in Java used to iterate over an array of Strings named computerScientists?

for (String scientist : computerScientists) { ... }

7
New cards

What is the key difference between Java's enhanced for-loop and a traditional for-loop regarding array modification?

"In a traditional for-loop

8
New cards

"In Java

what is an enum used for?"

9
New cards

"In the context of the reference manager assignment

what OOP concept allows the displayPapers() method to call the correct displayInfo() method for different types of papers?"

10
New cards

The relationship where a reference manager contains a list of research papers is an example of what OOP principle?

Composition (a 'has-a' relationship).

11
New cards

What error message might indicate that a class constructor is missing necessary parameters?

'constructor… cannot be applied to given types' or 'actual and formal argument lists differ in length'.

12
New cards

"In an inheritance hierarchy

what are the terms for the class being inherited from and the class that inherits?"

13
New cards

What Java keyword is used to indicate that one class is inheriting from another?

The extends keyword.

14
New cards

The OOP principle of reusing properties and behaviour from an existing class is known as _.

Inheritance

15
New cards

The OOP principle that involves building a class from objects of other classes to gain functionality is known as _.

Composition

16
New cards

What is the term for a concrete object that has been created from a class blueprint?

An instance.

17
New cards

What does the void keyword signify in a Java method declaration?

It indicates that the method does not return any value.

18
New cards

What is the core idea of polymorphism in OOP?

It allows a single method or object to behave differently when called for different subclasses of the same superclass.

19
New cards

"In the Developer example

FrontendDeveloper and BackendDeveloper both have a preferredLanguage() method. This is an example of what?"

20
New cards

Distinguish between the 'is-a' and 'has-a' relationships in OOP.

"Inheritance represents an 'is-a' relationship (a Car 'is-a' Vehicle)

21
New cards

What is the purpose of an access modifier in Java?

"To set the visibility and accessibility level for classes

22
New cards

"If an attribute is declared as private

where can it be accessed?"

23
New cards

How can code outside a class access a private variable from that class?

By using public 'get' and 'set' methods (getters and setters) provided by the class.

24
New cards

What is the visibility of a member declared with the protected access modifier?

"It is accessible within its own class

25
New cards

What are the four foundational principles (pillars) of Object-Oriented Programming?

"Encapsulation

26
New cards

"In Java

every function must exist inside a _

27
New cards

What is the difference between the logical AND operators in Python and Java?

"Python uses the keyword and

28
New cards

What is the defining characteristic of a do-while loop compared to a while loop?

A do-while loop's body is always executed at least once because the condition is checked at the end of the loop.

29
New cards

What is the purpose of the Scanner class in Java?

"It is a tool from the java.util package used for reading input from various sources

30
New cards

Which Scanner method reads all characters until the user presses 'ENTER'?

The nextLine() method.

31
New cards

What does it mean to 'override' a method in a subclass?

It means the subclass provides its own specific implementation for a method that is already defined in its superclass.

32
New cards

What are the four main rules for a valid method override in Java?

"It must have the same name

33
New cards

What is the purpose of the super keyword in a subclass?

It is used to refer to members (attributes and methods) of the immediate parent class.

34
New cards

"If you write vehicleSound() inside an overridden vehicleSound() method in the Car subclass

what would happen?"

35
New cards

What is the effect of declaring a class with the final keyword?

A final class cannot be extended or inherited by any other class.

36
New cards

What happens if you try to override a method that was declared as final in the superclass?

The code will not compile; final methods cannot be overridden.

37
New cards

"If no access modifier is specified for a class member

what is its visibility?"

38
New cards

The ability to define multiple methods with the same name but different parameters in the same class is known as _.

Method overloading

39
New cards

Method overloading is a form of _-time polymorphism.

compile

40
New cards

Method overriding is a form of _-time polymorphism.

run

41
New cards

What is the key difference between how an abstract class and an interface are used by a subclass?

"A subclass extends an abstract class

42
New cards

Can a single Java class inherit from multiple classes and implement multiple interfaces simultaneously?

"No

43
New cards

"In a UML class diagram

what symbol is used to denote a public member?"

44
New cards

"In a UML class diagram

what symbol is used to denote a private member?"

45
New cards

"In a UML class diagram

what symbol is used to denote a protected member?"

46
New cards

How is an inheritance relationship depicted in a UML class diagram?

"With a solid line and a hollow

47
New cards

How is an interface implementation (realization) depicted in a UML class diagram?

"With a dashed line and a hollow

48
New cards

What is the UML notation for a composition relationship?

A solid line with a filled diamond at the end connected to the 'whole' or composite class.

49
New cards

What is the UML notation for an aggregation relationship?

A solid line with a hollow diamond at the end connected to the 'whole' or aggregate class.

50
New cards

What is the key difference between composition and aggregation?

"In composition

51
New cards

What is the intent of the Factory Method design pattern?

"To provide an interface for creating objects in a superclass

52
New cards

What is the intent of the Singleton design pattern?

To ensure that a class has only one instance and to provide a global point of access to it.

53
New cards

What is a common use case for the Singleton pattern?

"To control access to a shared resource

54
New cards

"In a Java switch statement

what is the purpose of the break keyword?"

55
New cards

"In Java

what is the purpose of the continue statement within a loop?"

56
New cards

Which OOP pillar is primarily concerned with bundling data (attributes) and methods that operate on the data into a single unit or class?

Encapsulation.

57
New cards

"Which OOP pillar is concerned with hiding complex implementation details behind a simple

high-level interface?"

58
New cards

"What is the output of the following Java code?

59
New cards

System.out.println(""Line 1 \nLine 2"");"

"The code prints ""Line 1"" and ""Line 2"" on two separate lines."

60
New cards

What must be done before a Java source file can be executed?

It must be compiled from human-readable code into executable bytecode using a compiler like javac.

61
New cards

What is the name of the special method in a Java class that is the starting point for program execution?

The main method.

62
New cards

"In UML

what does it mean if a class name is written in italics?"

63
New cards

What does a dashed arrow in a UML class diagram typically represent?

"A dependency relationship

64
New cards

"In UML multiplicity notation

what does 1..* signify?"

65
New cards

"In the logistics example

the Logistics class contains a createTransport() method. Subclasses like RoadLogistics and SeaLogistics override this method to return specific objects (Truck or Ship). This describes which design pattern?"

66
New cards

The Singleton pattern often uses a _ constructor to prevent other classes from creating new instances.

private

67
New cards

How does a client typically get the single instance of a Singleton class?

"By calling a static public method

68
New cards

"According to the course materials

students often confuse inheritance with _."

69
New cards

"If a method in a subclass has the same name as a method in its superclass but different parameters

this is known as _."

70
New cards

Which collection type in Java is described as an array from java.util that stores ordered elements and can be instantiated?

ArrayList.

71
New cards

What does the SOLID acronym stand for in object-oriented design?

"Single responsibility