1/70
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
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.
Can an object be created directly from an abstract class?
"No
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.
What kind of class is described as a 'completely abstract class' used to group related methods?
An interface.
"If a class in Java implements an interface but does not provide implementations for all its methods
what must be done?"
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) { ... }
What is the key difference between Java's enhanced for-loop and a traditional for-loop regarding array modification?
"In a traditional for-loop
"In Java
what is an enum used for?"
"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?"
The relationship where a reference manager contains a list of research papers is an example of what OOP principle?
Composition (a 'has-a' relationship).
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'.
"In an inheritance hierarchy
what are the terms for the class being inherited from and the class that inherits?"
What Java keyword is used to indicate that one class is inheriting from another?
The extends keyword.
The OOP principle of reusing properties and behaviour from an existing class is known as _.
Inheritance
The OOP principle that involves building a class from objects of other classes to gain functionality is known as _.
Composition
What is the term for a concrete object that has been created from a class blueprint?
An instance.
What does the void keyword signify in a Java method declaration?
It indicates that the method does not return any value.
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.
"In the Developer example
FrontendDeveloper and BackendDeveloper both have a preferredLanguage() method. This is an example of what?"
Distinguish between the 'is-a' and 'has-a' relationships in OOP.
"Inheritance represents an 'is-a' relationship (a Car 'is-a' Vehicle)
What is the purpose of an access modifier in Java?
"To set the visibility and accessibility level for classes
"If an attribute is declared as private
where can it be accessed?"
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.
What is the visibility of a member declared with the protected access modifier?
"It is accessible within its own class
What are the four foundational principles (pillars) of Object-Oriented Programming?
"Encapsulation
"In Java
every function must exist inside a _
What is the difference between the logical AND operators in Python and Java?
"Python uses the keyword and
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.
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
Which Scanner method reads all characters until the user presses 'ENTER'?
The nextLine() method.
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.
What are the four main rules for a valid method override in Java?
"It must have the same name
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.
"If you write vehicleSound() inside an overridden vehicleSound() method in the Car subclass
what would happen?"
What is the effect of declaring a class with the final keyword?
A final class cannot be extended or inherited by any other class.
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.
"If no access modifier is specified for a class member
what is its visibility?"
The ability to define multiple methods with the same name but different parameters in the same class is known as _.
Method overloading
Method overloading is a form of _-time polymorphism.
compile
Method overriding is a form of _-time polymorphism.
run
What is the key difference between how an abstract class and an interface are used by a subclass?
"A subclass extends an abstract class
Can a single Java class inherit from multiple classes and implement multiple interfaces simultaneously?
"No
"In a UML class diagram
what symbol is used to denote a public member?"
"In a UML class diagram
what symbol is used to denote a private member?"
"In a UML class diagram
what symbol is used to denote a protected member?"
How is an inheritance relationship depicted in a UML class diagram?
"With a solid line and a hollow
How is an interface implementation (realization) depicted in a UML class diagram?
"With a dashed line and a hollow
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.
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.
What is the key difference between composition and aggregation?
"In composition
What is the intent of the Factory Method design pattern?
"To provide an interface for creating objects in a superclass
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.
What is a common use case for the Singleton pattern?
"To control access to a shared resource
"In a Java switch statement
what is the purpose of the break keyword?"
"In Java
what is the purpose of the continue statement within a loop?"
Which OOP pillar is primarily concerned with bundling data (attributes) and methods that operate on the data into a single unit or class?
Encapsulation.
"Which OOP pillar is concerned with hiding complex implementation details behind a simple
high-level interface?"
"What is the output of the following Java code?
System.out.println(""Line 1 \nLine 2"");"
"The code prints ""Line 1"" and ""Line 2"" on two separate lines."
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.
What is the name of the special method in a Java class that is the starting point for program execution?
The main method.
"In UML
what does it mean if a class name is written in italics?"
What does a dashed arrow in a UML class diagram typically represent?
"A dependency relationship
"In UML multiplicity notation
what does 1..* signify?"
"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?"
The Singleton pattern often uses a _ constructor to prevent other classes from creating new instances.
private
How does a client typically get the single instance of a Singleton class?
"By calling a static public method
"According to the course materials
students often confuse inheritance with _."
"If a method in a subclass has the same name as a method in its superclass but different parameters
this is known as _."
Which collection type in Java is described as an array from java.util that stores ordered elements and can be instantiated?
ArrayList.
What does the SOLID acronym stand for in object-oriented design?
"Single responsibility