Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

SD 2 – Object-Oriented Programming 4

Rating
-
Sold
-
Pages
30
Grade
A+
Uploaded on
17-03-2025
Written in
2024/2025

SD 2 – Object-Oriented Programming 4

Institution
Object-oriented Programming
Course
Object-oriented programming

Content preview

1. Which of the following OOP principles is used when a child class reuses

methods from a parent class?

A. Abstraction

B. Encapsulation

C. Inheritance

D. Polymorphism

Answer: C) Inheritance

Rationale: Inheritance allows a subclass to inherit methods and properties from a

superclass.




2. Which of the following is true about the "abstract" keyword?

A. It is used to create instances of a class

B. It defines the behavior of a method in a class

C. It indicates that a class cannot have any methods

D. It defines methods that must be implemented by derived classes

Answer: D) It defines methods that must be implemented by derived classes

,Rationale: The abstract keyword is used to define methods in an abstract class that

must be implemented by any non-abstract subclass.




3. What is the main purpose of the protected access modifier?

A. To allow access to class members from the same class and its subclasses

B. To restrict access to class members to only within the class

C. To allow access to class members from anywhere in the program

D. To allow access to class members from only within its package

Answer: A) To allow access to class members from the same class and its

subclasses

Rationale: The protected access modifier allows access to class members from the

class itself and its subclasses.




4. What does the private access modifier mean in OOP?

A. The member is accessible only within its class

B. The member is accessible from any class

C. The member is accessible from its package only

D. The member is accessible from subclasses

, Answer: A) The member is accessible only within its class

Rationale: The private access modifier restricts access to members of a class from

any other class except the class where it is declared.




5. Which of the following is a feature of object-oriented programming?

A. Data is hidden

B. Data is manipulated directly

C. Functions are not used

D. Programs are written in a procedural way

Answer: A) Data is hidden

Rationale: One of the key features of OOP is data encapsulation, which means data

is hidden from outside access and can only be accessed through public methods.




6. Which keyword is used to prevent a class from being inherited in OOP?

A. static

B. private

C. final

D. abstract

Written for

Institution
Object-oriented programming
Course
Object-oriented programming

Document information

Uploaded on
March 17, 2025
Number of pages
30
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$10.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
douglasmugwe82
5.0
(1)

Get to know the seller

Seller avatar
douglasmugwe82 Teachme2-tutor
Follow You need to be logged in order to follow users or courses
Sold
2
Member since
1 year
Number of followers
0
Documents
4239
Last sold
7 months ago
fully answered questions and answer

fully answered questions and answer

5.0

1 reviews

5
1
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions