Linkedin-Skill-Assessments-Quizzes - Object-Oriented-Programming-Quiz - MD at Main Ebazhanov - Linkedin-Skill-Assessments-Quizzes GitHub
Linkedin-Skill-Assessments-Quizzes - Object-Oriented-Programming-Quiz - MD at Main Ebazhanov - Linkedin-Skill-Assessments-Quizzes GitHub
main
8 contributors
any method
method overloading
method overriding
compiling
Q2. For which case would the use of a static attribute be appropriate?
Q3. 1 Why would you create an abstract class, if it can have no real instances?
Q4. 2 Why would you create an abstract class, if it can have no real instances?
It implies encapsulation.
A superclass object has an IS-A relationship with its subclass.
It implies a virtual method.
A subclass object has an IS-A relationship with its superclass or interface
Q9. You want a method with behavior similar to a virtual method--it is meant to be overridden
--expect that it does not have a method body. It just has a method signature. What kind of
method should you use?
an abstract method
a public internal method
an internal method
a protected internal method
Q10. Which code creates a new object from the Employee class?
Q14. If a local class is defined in a function, what is true for an object of that class?
The object can be accessed, declared, and used locally in that function.
The object must be declared inside any other function.
The object is temporarily accessible outside the function.
The object can call all the other class members anywhere in the program.
Q15. Which two blocks are used to handle and check errors?
do and check
catching and trying
try and catch
do and while
Inheritance describes the ability to create new classes based on an existing class.
Inheritance means that a group of related properties, methods, and other members are
treated as a single unit or object.
Inheritance forces a class to have a single responsibility from only one parent.
Inheritance means that you will never have multiple classes that can be used
interchangeably, even though each class implements the same properties or methods in
different ways.
Q18. Which type of inheritance ,when done continuously, is similar to a tree structure?
multilevel
hierarchical and multiple
hierarchical
multiple
Q20. Which of the following is NOT an advantage of using getters and setters?
Association is a relationship where all objects have their own life cycle and there is no owner.
Association is the process where model elements cooperate to provide higher-level
behavior.
Association is whole/part relationship where one object is composed of one or more other
objects, each of which is considered a part of the whole.
Association is where all objects have their own life cycle, but there is ownerhip, and child
objects can not belong to another parent object.
Q23. Which type of inheritance must be used so that the resultant is hybrid?
multiple
any type of inheritance
multilevel
hierarchical
- Single Inheritance is where a derived class inherits properties and behaviour from a
single base class. Example: Class A → Class B.
- Hierarchical Inheritance is where more than one derived class is created from a
single base class. Example: Class A → Class B → Class C.
- Multiple Inheritance is for deriving a class from multiple base classes. Here, the
child objects programmers create will have combined aspects of characteristics and
features from multiple parent classes. These objects do follow their hierarchies of
base classes.
- Multilevel Inheritance is where a child class is derived from another derived class.
This feature carries combined aspects of multiple classes and follows their
hierarchies.
- Hybrid Inheritance is a heterogeneous feature of using multiple inheritances. Here a
child class is derived from one or more combinations of single, hierarchical, and
multilevel inheritances. This inheritance is adopted for programs to mix different
types of inheritance; for example, when mixing a single inheritance with multiple
inheritances or maybe a situation when multiple inheritances are mixed within a single
program.
reference
Q24. A language that does not support polymorphism but supports classes is considered
what?
an object-based language
a class-based language
a procedure-oriented language
if classes are supported, polymorphism will be supported
Q25. Two classes combine private data members and provide public member functions to
access and manipulate those data members. Where is abstraction used?
Q26. What are the five Creational Design patterns by the Gang of Four ?
Q28. if an object is passed by reference, the changes made in the function are reflected _.
a set of instructions designed to perform a frequently used operation within a program and
return no values
the exact same thing as a function and subroutine
a set of variables that can change over time
a procedure associated with data and behaviour
Q30. A mobile phone is made up of components such as a motherboard, camera, and sensors.
The motherboard represents all the functions of a phone, the display shows the display only,
and the phone is represented as a whole. Which of the following has the highest level of
abstraction?
camera
display
motherboard
mobile phone
Q31. Which class has the highest degree of abstraction in a multilevel inheritance relationship
of five levels?
multilevel inheritance
double inheritance
single inheritance
hierarchical inheritance
It is called initially when an object is created and called with every new object instance.
It is called when an object is destroyed and only one time.
It is called initially when an object is created and only one time.
It is created at time when the object is discarded.
Q35. What does the code shown below demonstrate, and why?
Code Responsibility Collection cards are a brainstorming tool used in the design of
procedural software
Class Responsibility collaboration cards are a brainstorming tool used in the design of oop
software
Code Responsibility Correction cards are tools used for debugging
Code Responsibility Correction cards are tools for modeling
reference link
if one element of an aggregation is dereferenced, all its elements are eligible for garbage
collection
if a composition dies, the contents die
the contents of a composition are all siblings
an aggregation contains only abstract classes
Q39. 2 Which statement about compositions and aggregations is true?
if one element of an aggregation is dereferenced, all its elements are eligible for garbage
collection
if a composition dies, the contents die
the contents of a composition are all siblings
an aggregation contains only abstract classes
Member functions can be defined only inside or outside the class body.
Member functions can be made to be friends of another class.
Member functions do not need to be declared inside the class definition.
All member functions need to be defined.
NOTE: I don't have 4th variant in my test, it changed to new 5th variant. Is it also true?
Q43. In addition to attributes and behaviours, what quality must a class possess?
a name
a state
a color
an object
inline function
undefined function
virtual function
class member function
Q45. Which words in the following list are candidates for objects: trumpet, clean, enrage, leaf,
tree, collapse, active, and lively?
leaf and tree
clean, enrage, and collapse
clean, active, and lively
leaf, tree, and trumpet
No, abstract classes can be used only in single-level inheritance since they must be
immediately implemented.
yes, always
yes, but with only one abstract class
No, abstract classes do not have constructors.
single level
multilevel
hierarchical
multiple
Objects may maintain internal state, which is not easily accessible by the tests.
The quality of unit testing frameworks for functional languages is better.
OOP promotes code reuse, which means that your tests have to consider more use cases.
Object-oriented languages tend to rely on frameworks such as Spring or Hibernate, which
make them difficult to test.
Q55. The open/closed principle states that classes should be open for _ but closed for _.
refactoring; duplication
modification; duplication
extension; modification
reuse; encapsulation
It is a unique constructor for creating a new object as a copy of an object that already exists.
There will always be only one copy constructor that can be either defined by the user or the
system.
It is a constructor that duplicates itself when requested on demand.
It is a common constructor for preventing the creation of a new object as a copy of an object
that already exists. There will always be multiple standard constructors that can be either
defined by the user or the system.
It is a constructor that duplicates itself on its own, based on memory available.
The catch block that will be executed is the one that best matches the type of exception
thrown.
Multiple catch blocks can never be associated with a single try block.
Multiple catch blocks are mandatory for each try block.
Multiple catch blocks will all be executed in the case of an exception.
Q59. There are five classes. Class E is derived from class D, D from C, C from B, and B from A.
Which class constructor(s) will be called first if the object of E or D is created?
A
B
C
C and B
Q60. You have modules that are dependent on each other. If you change one module, you
have to make changes in the dependent modules. What term is used to describe this problem,
and what is a potential solution?
Cohesion. A solution is to show that each module has certain responsibilities and to use an
anticohesive design pattern.
Encapsulation. A solution is to implement one of the SOLID principles to ensure the modules
do not encapsulate with each other.
Coupling. A solution is to refactor the code to be loosely coupled by using inversion of
control and dependency injection.
Dependency. A solution is to implement polymorphism and abstraction to change and
extract dependent elements of a module so that it functions on its own.
A class of resources
A group of methods
A collection of objects
A list of children
virtual function
inline function
undefined function
private function
Q64. Are you required to return an object if it was passed by reference to a function, and why
or why not?
...
car:toyota
ducks:pond
toes:feet
rock:stone
Q67. Which statements best describe the Gang of Four design patterns called Memento and
Observer?
Memento notifies multiple classes of changes. Observer captures and restores an object's
internal state.
Memento defers the exact steps of an algorithm to a subclass. Observer defines a new
operation to a class without change.
Memento alters an object's behavior when its state changes. Observer encapsulates an
algorithm inside a class.
Memento captures and restores an object's internal state. Observer notifies multiple classes
of changes.
Q68. What does the value (0.5,0.5,0.5) indicate in the class diagram specification position:
Coordinate = (0.5,0.5,0.5)?
Q69. What is the most accurate example of the Liskov substitution principle?
A
public class Car{
}
public class FlyingCars extends Car{
public void fly(){}
}
public class Tesla FlyingCar{}
public class Honda Car{}
reference link
An argument can have many values while a parameter can have only one value.
An argument is the variable used for input values in a method. A parameter is the specific
input value passed to the method.
A parameter is a variable in the declaration of a function. An argument is the value of this
variable that gets passed to the function.
Parameters and arguments are the same
Protected scope
Private scope
Global scope
Depends on access specifier and inheritance used
Explanation: It depends on the access specifier and the type of inheritance used with the
class, because if the class is inherited then the nested class can be used by subclass too,
provided it’s not of private type.
Q72. Methods and attributes that define an object are a kind of blueprint called what?
a collection
a variable
a class
a procedure
Q73. Assume single inheritance is used with classes A and B while A is the base class. Then
assume classes C, D, and E, where C is a base class and D is derived from C, then E is derived
from D. Class C is made to inherit from class B. Which type of inheritance is reflected?
Multilevel
Hybrid
Single level
Multiple
To always run the finally block of code when the try block exits
To run code when an exception has not occurred
To run the block if an exception occurred
To run code whenever garbage collection requires it
C#
Java
C
Python
Protected class
Base class
Anonymous class
Abstract class
Composition is the act of one object passing to another object an operation to be performed
on behalf of the initial object.
Composition is a part/whole relationship where an object is composed of one or more other
objects, each of which is considered a part of the whole.
Composition is a binding where the class/name association is not made until the object
designated by the name is created at execution time
Composition is a process of collecting classes that provide a set of services for a particular
domain
overloading
inheritance
abstraction
overriding
parents
pure virtual functions
attributes
purposes
Q83. What is the difference between early binding and late binding?
Early binding is when a variable is assigned a value when a scope is created. Late binding is
when a variable is assigned a value after a scope is exited
Early binding is when a variable is assigned a value when the program starts. Late binding is
when a variable is assigned after the program is running
There is no difference. In both cases, variables are assigned values when a program has
completed startup and is running
Early binding is when a variable is assigned its value at compile time. Late binding is when a
variable is assigned a value at run time
Interfaces can contain code or data. Abstract classes do not contain code or data. A class can
inherit from more than one abstract class but can only implement one interface
Interfaces can contain code or data. Abstract classes do not contain code or data. A class can
inherit from only one abstract class but can implement an unlimited number of interface
Abstract classes can contain code or data. Interface do not contain code or data. A class can
inherit from only one abstract class but can implement an unlimited number of interfaces
Abstract classes can contain code or data. Interface do not contain code or data. A class can
inherit from more than one abstract class but can only implement one interface
Here they haven't mentioned any specific language so let's consider all languages.
reference to subclass // References to subclass are never required as you can simply Initialize
subclass & use their object.
reference to base class // References to the base class are not required in Java, Javascript &
Python
reference to this pointer // While Python & Javascript may require passing this or self in the
constructor, It is not passed in Java constructor.
none // Above 3 are incorrect so "none" is the answer
Q87. From the SOLID principles of object-oriented programming, which statement best
describes the Liskov substitution principle?
A class should have only a single responsibility—that is, only changes to one part of the
software's specification should be able to affect the specification of the class.
Software entities should be open for extension, but closed for modification.
Many client-specific interfaces are better than one general-purpose interface.
objects in a program should be replaceable with instances of their subtypes without altering
the correctness of that program.
Q88. In addition to responsibilities, what should be listed on Class-responsability-
collaboration (CRC) cards?
Q89. What is the best name for the function that corrects this assessment?
makeResult()
questionScore()
calculateScore()
getAnswers()
cat : kitten
color : red
planet : moon
truck : window
overloading constructors
overloading member functions
static member functions
overloading predefined operator
Encapsulation
Compilation
Inheritance
Polymorphism
Reference
Reference
class employee{int rating;}; class stream{int total;}; class topper: employee, stream{
};
Reference
Q100. Can you have two classes with the same name in the same proiect?
No, you cannot.
Yes, as long as their constructors are different.
Yes, as long as their methods are different.
Yes, as long as they are in different namespaces.