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 1

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

SD 2 – Object-Oriented Programming 1

Institution
Object-oriented Programming
Course
Object-oriented programming

Content preview

1. What is method overloading in OOP?

A. The ability of an object to take on many forms

B. Defining methods with the same name but different parameter types

C. Defining a method in multiple classes with different behavior

D. Reusing a method from a parent class

Answer: B) Defining methods with the same name but different parameter types

Rationale: Method overloading allows defining multiple methods with the same

name but different parameter types or counts.




2. What does the static keyword indicate about a method or variable in OOP?

A. It belongs to an instance of the class

B. It is shared among all instances of the class

C. It cannot be accessed from outside the class

D. It must be overridden in subclasses

Answer: B) It is shared among all instances of the class

,Rationale: A static method or variable is shared across all instances of the class and

can be accessed without creating an instance of the class.




3. Which of the following is an example of a real-world object that can be

represented in an object-oriented system?

A. An integer

B. A car, with properties like color and speed

C. A function that performs calculations

D. A constant value

Answer: B) A car, with properties like color and speed

Rationale: A real-world object like a car can be represented in OOP with attributes

(properties) and methods (behaviors).




4. Which of the following is a valid reason to use interfaces in OOP?

A. To provide a concrete implementation of methods

B. To define a contract that classes must follow

C. To allow inheritance of properties

D. To provide access to the instance variables of other classes

, Answer: B) To define a contract that classes must follow

Rationale: An interface defines a set of methods that any implementing class must

provide, promoting a contract-based approach.




5. 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.




6. Which of the following can cause an infinite recursion?

A. A constructor calling a parent constructor

B. A method calling itself without a base case

C. A class using multiple inheritance

D. A method overloading with the same name

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