DEC/2025
REGIONAL MARITIME UNIVERSITY
ICT
BCS28
END OF SEMESTER EXAMINATION
BCME 207 OBJECT ORIENTED PROGRAMMING (JAVA)
INSTRUCTIONS: Answer Sections A and B and ANY TWO questions from Section C. Section
C should be done on the computer. Create a Folder with your index no and save your work in
the folder. Your work should be saved with the filename comprising your index number and the
question number (i.e BCS000134_Q1)
TIME ALLOWED: 3 Hours
SECTION A
1. Which of the following is NOT a fundamental concept of Object-Oriented
programming?
a) Encapsulation
b) Inheritance
c) Polymorphism
d) Exception Handling
2. What is the primary way to achieve Encapsulation in Java?
a) Using the public access modifier for all variables.
b) Making class variables private and providing public getter/setter methods.
c) Defining the class as abstract.
d) Using the Static keyword for methods.
3. In Java, a class can inherit from how many other classes?
a) Zero or one
b) Only one
c) One or more
d) Multiple (up to ten)
4. Which of the following defines Method Overloading?
a) Methods in a subclass having the same name and signature as in the superclass.
b) Methods with the same name but different parameter lists within the same class.
c) A class having multiple constructors
d) Using an interface reference to refer to an object of a concrete class.
Doc. No.: EXM/F/03 Page No.: 1/8 Issue No.: 1 Last Update: 15/05/15
Revision No.: 2 Date: 12/04/06 Author: EC Approved: PROVOST
5. What must be true for a method to override another method?
a) It must have a different return type.
b) It must have a different access modifier
c) It must have the exact same name, return type, and parameter list as
the superclass method.
d) It must be defined as static.
6. What is the main purpose of an Abstract Class?
a) To prevent the class from being instantiated and serve as a base for
other classes.
b) To group related static methods
c) To allow a class to inherit from multiple other classes.
d) To define a contract for what a class can do without specifying how it
does it.
7. Which access modifier restricts access to only the class itself, and no other
classes(not even subclasses)?
a) protected
b) public
c) default
d) private
8. What is the purpose of the keyword super( ) inside a subclass constructor?
a) To call a static method in the superclass.
b) To call the superclass’s no argument constructor.
c) To explicitly create an instance of the superclass.
d) To refer to an instance variable in the superclass.
9. A class that implements an Interface must:
a) Declare all methods as static.
b) Override all abstract methods defined in the interface.
c) Be defined as an abstract class.
d) Extend an abstract class
[Link] the final keyword is applied to a method, what does it prevent?
a) The method from being called.
b) The method from being overloaded.
c) The method from being overridden by subclasses.
d) The method from having parameters.
[Link] access modifier is usually used for data members of a class?
a) Protected
b) Final
c) Public
d) Private
[Link] Java a try block should immediately be followed by one or more _____
blocks.
Doc. No.: EXM/F/03 Page No.: 2/8 Issue No.: 1 Last Update: 15/05/15
Revision No.: 2 Date: 12/04/06 Author: EC Approved: PROVOST
a) Throw
b) Run
c) error
d) catch
[Link] object-oriented programming, the process by which a class acquires the
properties of another class is called
a) Encapsulation
b) Polymorphism
c) Inheritance
d) Overriding
e) Overloading
[Link] is the object created with new keyword?
a) At run-time
b) At compile time
c) Depends on the code
d) None
[Link] the correct definition of a package
a) A package is a collection of editing tools.
b) A package is a collection of classes.
c) A package is a collection of classes and interfaces.
d) A package is a collection of interfaces.
[Link] the keyword among the following that makes a variable belong to a
class, rather than being defined for each instance of the class.
a) final
b) static
c) volatile
d) abstract
[Link] the return type of a method that does not return any value.
a) int
b) void
c) double
d) none
[Link] the modifier which cannot be used for constructor.
a) public
b) protected
c) private
d) static
[Link] declared in a class for the use of all
a) Object
b) Instance variables
Doc. No.: EXM/F/03 Page No.: 3/8 Issue No.: 1 Last Update: 15/05/15
Revision No.: 2 Date: 12/04/06 Author: EC Approved: PROVOST
c) Reference variables
d) None
[Link] the correct way of declaring constructor.
a) Solution(){}
b) public Solution(){}
c) Solution(void){}
d) Both
[Link] created by try block is caught in which block
a) catch
b) throw
c) final
d) none
[Link] Oriented Programming
a) makes program more reliable
b) simulates real life
c) uses a lot of vocabulary, which is not bad as it sounds
d) is all of the above
[Link] actions in Java are called
a) procedures
b) functions
c) methods
d) subroutine
[Link] two methods have the same name but different parameter list then it is
called ______
a) Method overriding
b) Method overloading
c) Operator loading
d) None of these
[Link] mechanism of deriving a new class from an old one is called __________
a) Method overriding
b) Method overloading
c) Operator loading
d) Inheritance
26.________ keyboard does not allow a method to be override in the subclass
a) Public
b) Final
Doc. No.: EXM/F/03 Page No.: 4/8 Issue No.: 1 Last Update: 15/05/15
Revision No.: 2 Date: 12/04/06 Author: EC Approved: PROVOST
c) Abstract
d) Static
27._____ is a special method in Java that enables an object to initialize itself
when created.
a) Constructor b) Destructor c) Static d)Final
[Link] of the following is NOT a Java keyword?
a) object
b) new
c) package
d) static
[Link] of the following is NOT a [Link] method?
a) nextInt
b) hasNext
c) nextLine
d) nextString
[Link] a Java program run, what happens when the JVM tries to open an
input file that does not exist?
a) The JVM will throw a FileNotFoundException
b) The JVM will treat it as if it was an empty file.
c) The JVM will skip over all further program statements relating to this
file
d) The JVM will terminate the program without throwing an exception.
[Link] of the following is TRUE about abstract classes?
a) They can be instantiated directly
b) They can only contain abstract methods
c) They cannot contain concreate methods
d) They may contain both abstract and concrete methods
[Link] is an abstract method?
a) A method with a default implementation
b) A method without a body
c) A method that cannot be overridden
d) A private method
33. Which keyword is used to declare an abstract class in Java?
a) interface
b) class
c) abstract
d) extends
[Link] happens if a subclass fails to implement all abstract methods of its
abstract superclass?
Doc. No.: EXM/F/03 Page No.: 5/8 Issue No.: 1 Last Update: 15/05/15
Revision No.: 2 Date: 12/04/06 Author: EC Approved: PROVOST
a) Nothing happens
b) The subclass becomes abstract
c) A runtime error occurs
d) The program compiles successfully
[Link] of the following is TRUE about interfaces?
a) All methods must have bodies
b) Interfaces can be instantiated
c) Interfaces contain only abstract methods
d) Interfaces can extend multiple classes
[Link] does an interface define?
a) Method implementations
b) A contract of method signatures
c) Constructors
d) Private methods only
[Link] key word is used to implement an Interface?
a) extends
b) implements
c) inherits
d) interface
38.A class can:
a) Extend multiple classes
b) Implement multiple interfaces
c) Implement only one interface
d) Extend multiple interfaces
[Link] is the relationship between interfaces?
a) They cannot inherit from one another
b) Interfaces can extend other interfaces
c) Interface can extend classes
d) Interfaces must always be final
[Link] is it recommended to use an abstract class instead of an interface?
a) When only abstract methods are needed
b) When you want to provide shared implementation
c) When a class must extend multiple classes
d) When no inheritance is needed
SECTION B
1. Explain what is meant by polymorphism in object-oriented programming.
Give one benefit of polymorphism. [3 marks]
Doc. No.: EXM/F/03 Page No.: 6/8 Issue No.: 1 Last Update: 15/05/15
Revision No.: 2 Date: 12/04/06 Author: EC Approved: PROVOST
2. Describe the different ways that object-oriented programming languages
implement the concept of polymorphism. [9 marks]
3. What is the difference between Method Overloading and Method Overriding?
[4 marks]
4. Define the following:
i. Constructor [2 marks]
ii. Class [2 marks]
iii. Object [2 marks]
iv. Access modifiers [2 marks]
v. Interface Polymorphism [2 marks]
5. How can multiple inheritance be achieved in Java? [2 marks]
6. Why is the private access modifier important in object-oriented
programming?
[2 marks]
SECTION C
Question 1
Create an abstract class Animal with:
A concrete method eat() that prints "Animal is eating".
Doc. No.: EXM/F/03 Page No.: 7/8 Issue No.: 1 Last Update: 15/05/15
Revision No.: 2 Date: 12/04/06 Author: EC Approved: PROVOST
An abstract method makeSound().
Then create two subclasses Dog and Cat that implement makeSound() differently.
Finally, write a main method to:
Create objects of Dog and Cat
Call eat() and makeSound() on each object
[15
Marks]
Question 2
Write a Java program to create a method that takes an integer as a parameter and
throws an exception if the number is odd.
[15 Marks]
Question 3
Create a class ‘Degree’ that prints “I got a degree”. It has two subclasses namely
‘Undergraduate’ and ‘Postgraduate’ each having a method with the same name that
prints “I am an Undergraduate” and “I am a Postgraduate” respectively. Call the
method by creating an object of each of the three classes.
[15 Marks]
Question 4
Create an interface Shape with a method area(). Implement two classes, Circle and
Rectangle, that provide their own implementations of the area() method. Test
polymorphism by calling the area method on different shape objects.
[15 Marks]
SEE
Doc. No.: EXM/F/03 Page No.: 8/8 Issue No.: 1 Last Update: 15/05/15
Revision No.: 2 Date: 12/04/06 Author: EC Approved: PROVOST