oop_test_2_2013_

Upload: anthony-pringle

Post on 04-Jun-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 OOP_TEST_2_2013_

    1/6

    OOP TEST 2

    2 hrs

    Instructions: Answer all questions within this document.

    Practical

    Question#1

    Write a class encapsulating the concept of a home, assuming that it has the following attributes: thenumber of rooms, the square footage, and whether it has a basement(boolean). [5mrks]

    Question2

    ou ma! use some of the information from "uestion#$ to answer this question.

    % de&eloper wants a program written to capture information regarding homes to be de&eloped. 'he

    program should allow a user to

    $. enter and store information regarding each house [mrks]

    . pro&ide report on a list of the details of all houses without basement [mrks]

    . pro&ide list with details of all houses [mrks]

    ou should also pro&ide the e*it option. [$mrk]

    +ncorporate the use of e*ception handling where necessar!. [ mrks]

    +ncorporate the use of files to make the data persistent. [ mrks]

    %ppropriate use of control structure,obect creation, method calls, etc. [mrks]

  • 8/13/2019 OOP_TEST_2_2013_

    2/6

    Theory

    .1 Inheritance is the process by which a new class known as a _________ - is created fromanother class, called the _____________.

  • 8/13/2019 OOP_TEST_2_2013_

    3/6

    .a base class, derived class

    .b derived class, base class

    .c inherited class, base class

    .d base class, inherited class

    .2 A derived class is also called a.a sub class.b super class.c base class.d all of the above

    . If the final modifier is added to the definition of a method, this means!.a "he method may be redefined in the derived class..b "he method may be redefined in the sub class..c "he method may not be redefined in the derived class..d #one of the above.

    .$ "he special synta% for invokin& a constructor of the base class is!.a super'(.b base'(.c parent'(

  • 8/13/2019 OOP_TEST_2_2013_

    4/6

    .d child'(

    .) A method or instance variable modified by protected! ****.a can not be accessed by name inside its own class definitions..b can not be accessed by name inside any class derived from it..c can not be accessed by name in the definition of any class in the same packa&e..d can not be accessed by name in any other class 'that is, other than classes named in

    a-c.(.

    .+ __________ refers to the ability to associate many meanin&s to one method name by meansof the late bindin& mechanism..a Inheritance.b ncapsulation.c olymorphism.d #one of the above

    . A class that has at least one abstract method is called an!.a concrete class.b encapsulated class.c abstract class.d private class

    ./ A class with no abstract methods is called a

  • 8/13/2019 OOP_TEST_2_2013_

    5/6

    .a concrete class

    .b encapsulated class

    .c abstract class

    .d private class

    .0 "he %ception class belon&s to the packa&e!.a ava.io.b ava.util.c ava.lan&.d ava.e%cept

    .1 "he catch block has ________ parameters..a 3ero.b one.c two.d three

    .11 If a method throws an e%ception, and the e%ception is not cau&ht inside the method, thenthe method invocation!.a terminates.b transfers control to the catch block.c transfers control to the e%ception handler.d none of the above

    .12 A runtime e%ception is a4an!.a checked e%ception.b unchecked e%ception.c offendin& e%ception.d none of the above

    .1 A _________ block e%ecutes re&ardless of whether an e%ception occurs..a final.b finally.c catch.d none of the above

    .1$ In 5ava, when you open a te%t file you should account for a possible!.a 6ile#ot6ound%ception.b 6ile6ull%ception.c 6ile#ot7eady%ception.d all of the above

    .1) A class that uses an interface must use the keyword!

    .a %tends.b Inherits

    .c 8uper

    .d Implements

    .1+ In 5ava, a derived class can have ________ base class'es(..a one.b two.c three.d there is no limit

    .1 9hich method is used to place an entire Array:ist into a file

  • 8/13/2019 OOP_TEST_2_2013_

    6/6

    .a write

    .b write;bect

    .c read6ile

    .d read;bect

    .1/ Laptop extends Computer. 9hich of the followin& is true based on the previous

    statement*

    .a :aptop is the superclass of