Java OOPS  (easy)

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

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

  • Object-oriented programming (correct)
  • Structured programming
  • Functional programming
  • Procedural programming

What is a class in Java?

  • A template that has certain attributes (correct)
  • A way to display data
  • A method to calculate simple interest
  • An instance of a class

What is an object in Java?

  • An instance of a class (correct)
  • A template that has certain attributes
  • A method to calculate simple interest
  • A way to display data

What does OOPs make the Java program?

<p>Reusable, easier to modify and debug (B)</p> Signup and view all the answers

What does the deposit method in the Bank class do?

<p>Adds the specified amount to the balance (A)</p> Signup and view all the answers

What does the calculateAmount method in the Bank class do?

<p>Calculates the amount with simple interest (C)</p> Signup and view all the answers

Which keyword is used to implement an interface in Java?

<p>implements (B)</p> Signup and view all the answers

What is the purpose of method overriding?

<p>To reduce unwanted code in a program (A)</p> Signup and view all the answers

Which of the following is true about interfaces in Java?

<p>Interfaces can be extended by other interfaces (B)</p> Signup and view all the answers

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

<p>public and final (B)</p> Signup and view all the answers

Can a class implement more than one interface in Java?

<p>Yes, Java allows a class to implement multiple interfaces (A)</p> Signup and view all the answers

Can an interface implement another interface in Java?

<p>No, an interface cannot implement another interface (A)</p> Signup and view all the answers

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

<p>Inherited constructor (B)</p> Signup and view all the answers

What is the purpose of constructors in Java?

<p>To initialize objects (D)</p> Signup and view all the answers

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

<p>Default constructor (D)</p> Signup and view all the answers

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?

<p>Multi-level inheritance (A)</p> Signup and view all the answers

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

<p>To show only the essential features while hiding the complex background details (C)</p> Signup and view all the answers

What is the return type of a constructor in Java?

<p>None of the above (D)</p> Signup and view all the answers

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

<p>To display all the members of the class (B)</p> Signup and view all the answers

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

<p>Runtime polymorphism (C)</p> Signup and view all the answers

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

<p>It cannot be inherited from (D)</p> Signup and view all the answers

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

<p>$amount = principal + (principal * rate * time) / 100$ (B)</p> Signup and view all the answers

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

<p>To override a method in the subclass (A)</p> Signup and view all the answers

Why does Java not support multiple inheritance?

<p>It creates confusion when there exist methods with the same name and the same arguments in superclasses and subclasses (A)</p> Signup and view all the answers

Which keyword is used to implement encapsulation in Java?

<p>private (B)</p> Signup and view all the answers

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

<p>To get and set the values of data members (A)</p> Signup and view all the answers

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

<p>324.0 (B)</p> Signup and view all the answers

What is the purpose of inheritance in Java?

<p>To increase reusability of code (B)</p> Signup and view all the answers

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

<p>extends (B)</p> Signup and view all the answers

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

<p>a: 10 b: 20 Model Name: Alto Mileage: 150 c: 15 d: 25 Model Name: Verna Mileage: 200 (D)</p> Signup and view all the answers

Flashcards are hidden until you start studying

More Like This

Use Quizgecko on...
Browser
Browser