click below
click below
Normal Size Small Size show me how
OOP F4 (M7 M8)
| Question | Answer |
|---|---|
| Here is a situation: Birthday happy; happy = new AdultBirthday( "Joe", 39); happy.greeting(); Which greeting() method is run: the one defined for Birthday or the one defined for AdultBirthday? | The one defined for AdultBirthday because that is the type of the object referred to by happy. |
| A method that is declared final cannot be overridden in a subclass. | true |
| An abstract class cannot have instance data and non-abstract methods. | false |
| Which among the following is the language which supports classes but not polymorphism? | Ada |
| Which of the following classes fail to compile? abstract class X { abstract void method(); } class Y extends X { } class Z extends Y { void method() { System.out.println("Class Z"); } } | Y |
| Can an abstract parent class have non-abstract children? | Yes--an abstract parent can have both abstract and non-abstract children. |
| What is an abstract class? | An abstract class is class which cannot be instantiated. |
| If two classes combine some private data members and provides public member functions to access and manipulate those data members. Where is abstraction used? | Using public member functions to access and manipulate the data members |
| Which of the following statement(s) is/are correct? X: An abstract class can have one or more abstract methods. Y: An abstract class can have only abstract. Non abstract (or concrete) methods are not allowed. | X only |
| X: By wrapping the desired code in a try block followed by a catch block to catch the exceptions. Y: List the desired exceptions in the throws clause of the method and let the caller of the method handle those exceptions. | Both X and Y |
| Which of these is a super class of all errors and exceptions in the Java language? | Throwable |
| Which symbol should be used to separate the type of exception handler classes in a single catch block? | | |
| To catch the exceptions ___________________ | An object must be created to catch the exception |
| Only way to enable assertion for your program is by using command line arguments. | False |
| Attempting to instantiate an object of an abstract class is a logic error. | false |
| What must a non-abstract child do about an abstract method in its parent class? | A child must override an abstract method inherited from its parent by defining a method with the same signature and same return type. |
| Polymorphism is a feature of object oriented programming. | True |
| Unfortunately, polymorphic programs make it difficult to add new capabilities to a system. | false |
| Which of the following is FALSE about abstract classes in Java | A class can inherit from multiple abstract classes. |
| Which of the following classes fail to compile? class X { abstract void method(); } abstract class Y extends X { } class Z extends Y { void method() { } } | X |
| MethodX might encounter an IOException or an AWTException, but handles neither. How should the header for methodX be written? | ... methodX(...) throws IOException, AWTException |
| What is an exception? | Problem arising during runtime |
| Program throws ___________ if assert statement fails. | java.lang.AssertionError |