Robert Bosch OOPS Quiz 3

Question 1

Time: 00:00:00
Which term is not commonly associated with OOP?

Polymorphism

Polymorphism

Encapsulation

Encapsulation

Pointers

Pointers

Inheritance

Inheritance

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 2

Time: 00:00:00
Which concept is not directly related to OOP?

Objects

Objects

Functions

Functions

Classes

Classes

Interfaces

Interfaces

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
Which is not a feature of OOP in general definitions?

Abstraction

Abstraction

Polymorphism

Polymorphism

Sequential Execution

Sequential Execution

Inheritance

Inheritance

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 4

Time: 00:00:00
What is the output of the following code snippet?

```
class Person:
def __init__(self, name, age):
self.name = name
self.age = age

class Employee(Person):
def __init__(self, name, age, salary):
super().__init__(name, age)
self.salary = salary

e = Employee("John", 25, 5000)
print(e.name, e.age, e.salary)
```

 

John 25 5000

John 25 5000

("John", 25, 5000)

("John", 25, 5000)

Error: 'Employee' object has no attribute 'name'

Error: 'Employee' object has no attribute 'name'

Error: 'Employee' object has no attribute 'salary'

Error: 'Employee' object has no attribute 'salary'

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 5

Time: 00:00:00
What is the output of the following code snippet?

```
class BankAccount:
def __init__(self, balance):
self.balance = balance

def deposit(self, amount):
self.balance += amount

def withdraw(self, amount):
if self.balance >= amount:
self.balance -= amount
else:
print("Insufficient balance")

class SavingsAccount(BankAccount):
def __init__(self, balance):
super().__init__(balance)

def withdraw(self, amount):
if self.balance >= amount + 100:
self.balance -= amount
else:
print("Minimum balance should be maintained")

s = SavingsAccount(1000)
s.withdraw(500)
print(s.balance)
```

 

500

500

1000

1000

400

400

Minimum balance should be maintained

Minimum balance should be maintained

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
What is the output of the following code snippet?

```
class Animal:
def __init__(self, name):
self.name = name

def speak(self):
print("Animal speaks")

class Dog(Animal):
def speak(self):
print("Woof!")

class Cat(Animal):
def speak(self):
print("Meow!")

class Horse(Animal):
pass

d = Dog("Buddy")
c = Cat("Whiskers")
h = Horse("Thunder")
d.speak()
c.speak()
h.speak()
```

 

 

Woof! Meow! Animal speaks

Woof! Meow! Animal speaks

Buddy Whiskers Thunder

Buddy Whiskers Thunder

Error: 'Horse' object has no attribute 'speak'

Error: 'Horse' object has no attribute 'speak'

Error: 'Animal' object has no attribute 'speak'

Error: 'Animal' object has no attribute 'speak'

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
What is the output of the following code snippet?

```
class Shape:
def __init__(self, sides):
self.sides = sides

def get_info(self):
return "This shape has " + str(self.sides) + " sides."

class Triangle(Shape):
def __init__(self):
super().__init__(3)

class Square(Shape):
def __init__(self):
super().__init__(4)

class Circle(Shape):
def __init__(self):
super().__init__(0)

t = Triangle()
s = Square()
c = Circle()
print(t.get_info())
print(s.get_info())
print(c.get_info())
```

This shape has 3 sides. This shape has 4 sides. This shape has 0 sides.

This shape has 3 sides. This shape has 4 sides. This shape has 0 sides.

This shape has 0 sides. This shape has 3 sides. This shape has 4 sides.

This shape has 0 sides. This shape has 3 sides. This shape has 4 sides.

Error: 'Circle' object has no attribute 'get_info'

Error: 'Circle' object has no attribute 'get_info'

Error: 'Shape' object has no attribute 'get_info'

Error: 'Shape' object has no attribute 'get_info'

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 8

Time: 00:00:00
What is the difference between an abstract class and an interface in OOP?

An abstract class can be instantiated, while an interface cannot

An abstract class can be instantiated, while an interface cannot

An abstract class can define both abstract and non-abstract methods, while an interface can only define abstract methods

An abstract class can define both abstract and non-abstract methods, while an interface can only define abstract methods

An abstract class can provide default implementations for some methods, while an interface cannot

An abstract class can provide default implementations for some methods, while an interface cannot

An abstract class can have constructors, while an interface cannot

An abstract class can have constructors, while an interface cannot

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 9

Time: 00:00:00
What is the purpose of exception handling in OOP?

To create multiple instances of a class

To create multiple instances of a class

To hide the internal details of an object

To hide the internal details of an object

To handle and recover from runtime errors

To handle and recover from runtime errors

To define a new class from an existing class

To define a new class from an existing class

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 10

Time: 00:00:00
What is the difference between checked and unchecked exceptions in OOP?

Checked exceptions are checked at compile-time, while unchecked exceptions are checked at runtime

Checked exceptions are checked at compile-time, while unchecked exceptions are checked at runtime

Checked exceptions are checked at runtime, while unchecked exceptions are checked at compile-time

Checked exceptions are checked at runtime, while unchecked exceptions are checked at compile-time

Checked exceptions are declared in the method signature or caught explicitly, while unchecked exceptions do not need to be declared or caught

Checked exceptions are declared in the method signature or caught explicitly, while unchecked exceptions do not need to be declared or caught

Checked exceptions are declared in the class definition, while unchecked exceptions are declared in the method definition

Checked exceptions are declared in the class definition, while unchecked exceptions are declared in the method definition

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

["0","40","60","80","100"]
["Need more practice!","Keep trying!","Not bad!","Good work!","Perfect!"]

Personalized Analytics only Availble for Logged in users

Analytics below shows your performance in various Mocks on PrepInsta

Your average Analytics for this Quiz

Rank

-

Percentile

0%

Completed

0/10

Accuracy

0%

Get Prepinsta Prime

Get all 200+ courses offered by Prepinsta

Never Miss an OffCampus Update

Get OffCampus Updates on Social Media from PrepInsta

Follow us on our Media Handles, we post out OffCampus drives on our Instagram, Telegram, Discord, Whatsdapp etc.

Get Hiring Updates
Amazon,Google,Delottie & 30+companies are hiring ! Get hiring Updates right in your inbox from PrepInsta

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.

Get PrepInsta Prime Subscription

Get access to all the courses that PrepInsta offers, check the out below -

Companies

TCS, Cognizant, Delloite, Infosys, Wipro, CoCubes, KPMG, Amazone, ZS Associates, Accenture, Congnizant & other 50+ companies

Programming

Data Structures, Top 500 Codes, C, C++, Java Python & other 10+ subjects

Skills

Full Stack Web Development, Data Science, Machine Learning, AWS Cloud, & other 10+ skills and 20+ projects