Java OOPS  (easy)
30 Questions
3 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

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</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</p> Signup and view all the answers

    What does the calculateAmount method in the Bank class do?

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

    Which keyword is used to implement an interface in Java?

    <p>implements</p> Signup and view all the answers

    What is the purpose of method overriding?

    <p>To reduce unwanted code in a program</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</p> Signup and view all the answers

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

    <p>public and final</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</p> Signup and view all the answers

    Can an interface implement another interface in Java?

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

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

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

    What is the purpose of constructors in Java?

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

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

    <p>Default constructor</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</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</p> Signup and view all the answers

    What is the return type of a constructor in Java?

    <p>None of the above</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</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</p> Signup and view all the answers

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

    <p>It cannot be inherited from</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$</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</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</p> Signup and view all the answers

    Which keyword is used to implement encapsulation in Java?

    <p>private</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</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</p> Signup and view all the answers

    What is the purpose of inheritance in Java?

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

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

    <p>extends</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</p> Signup and view all the answers

    More Like This

    Java OOPS (medium)
    30 questions

    Java OOPS (medium)

    AwedExuberance avatar
    AwedExuberance
    Java OOPs Concepts Quiz
    5 questions
    Java OOPs Concepts: Inheritance Types
    24 questions
    Use Quizgecko on...
    Browser
    Browser