Inheritance

Card Set Information

Author:
wgaynor
ID:
285136
Filename:
Inheritance
Updated:
2014-10-09 14:10:48
Tags:
Java
Folders:
Java
Description:
Studying
Show Answers:

Home > Flashcards > Print Preview

The flashcards below were created by user wgaynor on FreezingBlue Flashcards. What would you like to do?


  1. Which 2 statetments are true?

    A: The extends keyword is used to specify inheritance
    B: subclass of a non-abstract class cannot be declared abstract
    C: subclass of an abstract class can be declared abstract
    D: subclass of a final class cannot be abstract
    E: A class, in which all the members are declared private, cannot be declared public.
    • A: The extends keyword is used to specify inheritance.
    • C: subclass of an abstract class can be declared abstract.
  2. Which of the following statements are true?
    A: Subclasses must define all the abstract methods that the superclass defines.
    B: A class implementing an interface must define all the methods of that interface
    C: A class cannot override the super class's constructor
    D: It is possible for two classes to be the superclass of each other
    E: An interface can implement multiple interfaces
    C: A class cannot override the super class's constructor. (Because constructors are not inherited)
  3. In which order are the following executed;
    1. Static blocks of the base class
    2. Static blocks of the class
    3. Non-static blocks of the base class
    4. Constructor of the base class
    5. Non-static blocks of the class
    6. Constructor of the class
    • In that exact order.
    • Note: derived class's static or non-static blocks are not executed if that class is not being used.
  4. What will the following code print when compiled and run?

    class ABCD{
      int x = 10;
      static int y = 20;
    }
    class MNOP extends ABCD{
      int x = 30;
      static int y = 40;
    }
    public class TestClass {
      public static void main(String[] args) {
      System.out.println(new MNOP().x+", "+new   MNOP().y);
      }
    }
    30, 40

What would you like to do?

Home > Flashcards > Print Preview