Java OOPS (easy)

AwedExuberance avatar
AwedExuberance
·
·
Download

Start Quiz

Study Flashcards

30 Questions

Which programming paradigm focuses more on the data and related methods rather than procedures?

Object-oriented programming

What is a class in Java?

A template that has certain attributes

What is an object in Java?

An instance of a class

What does OOPs make the Java program?

Reusable, easier to modify and debug

What does the deposit method in the Bank class do?

Adds the specified amount to the balance

What does the calculateAmount method in the Bank class do?

Calculates the amount with simple interest

Which keyword is used to implement an interface in Java?

implements

What is the purpose of method overriding?

To reduce unwanted code in a program

Which of the following is true about interfaces in Java?

Interfaces can be extended by other interfaces

What are the default access modifiers for variables in an interface?

public and final

Can a class implement more than one interface in Java?

Yes, Java allows a class to implement multiple interfaces

Can an interface implement another interface in Java?

No, an interface cannot implement another interface

Which of the following is NOT a type of constructor in Java?

Inherited constructor

What is the purpose of constructors in Java?

To initialize objects

Which type of constructor is used to initialize objects with default values?

Default constructor

Which type of inheritance is shown in the example where class B is derived from class A and class C is derived from class B?

Multi-level inheritance

What is the purpose of data abstraction in object-oriented programming?

To show only the essential features while hiding the complex background details

What is the return type of a constructor in Java?

None of the above

What is the purpose of the displayData() method in the Bank class?

To display all the members of the class

Which type of polymorphism is demonstrated in the example where different subclasses of Animal have their own implementation of the 'eats()' method?

Runtime polymorphism

What happens if a class is declared as 'final' in Java?

It cannot be inherited from

What is the formula for calculating the amount for a particular principal amount, rate of interest, and time in the Bank class?

$amount = principal + (principal * rate * time) / 100$

What is the purpose of the '@Override' annotation in Java?

To override a method in the subclass

Why does Java not support multiple inheritance?

It creates confusion when there exist methods with the same name and the same arguments in superclasses and subclasses

Which keyword is used to implement encapsulation in Java?

private

What is the purpose of getter and setter methods in encapsulation?

To get and set the values of data members

What is the output of the program?

Amount calculated for Rs 300/- at a rate of 4.5% for 2 years is: 324.0 Name: null Account number: 0 Balance: 1500.0 Name: Tom Account number: 12345 Balance: 1000.0 Name: Harry Account number: 98765 Balance: 2000.0 Name: Tom Account number: 12345 Balance: 1000.0

324.0

What is the purpose of inheritance in Java?

To increase reusability of code

Which keyword is used to inherit properties from a parent class in Java?

extends

What is the output of the program?

a: 10 b: 20 Model Name: Alto Mileage: 150 c: 15 d: 25 Model Name: Verna Mileage: 200

a: 10 b: 20 Model Name: Alto Mileage: 150 c: 15 d: 25 Model Name: Verna Mileage: 200

Test your knowledge of Java programming by answering questions about object-oriented concepts and methods.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

Use Quizgecko on...
Browser
Browser