0% found this document useful (0 votes)
3 views2 pages

Object Oriented Programming Exam 2019

The document outlines the examination paper for the Bachelor of Science in Computer Science and Bachelor of Education, focusing on Object Oriented Programming. It includes various questions on key concepts such as inheritance, encapsulation, polymorphism, and exception handling, along with programming tasks in Java. The exam consists of multiple questions that require theoretical explanations and practical coding implementations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Object Oriented Programming Exam 2019

The document outlines the examination paper for the Bachelor of Science in Computer Science and Bachelor of Education, focusing on Object Oriented Programming. It includes various questions on key concepts such as inheritance, encapsulation, polymorphism, and exception handling, along with programming tasks in Java. The exam consists of multiple questions that require theoretical explanations and practical coding implementations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

UNIVERSITY EXAMINATION 2018/2019

YEAR II SEMESTER II EXAMINATION FOR THE BACHELOR OF SCIENCE IN COMPUTER SCIENCE AND
BACHELOR OF EDUCATION (MATH, COMPUTER)

SCS B204: OBJECT ORIENTED PROGRAMMING (EXAM A)


DATE: April 2019 TIME: 2 Hours
Instructions: Answer Question 1 and Any Other Two Questions.

QUESTION 1 (40 MARKS)


a) Explain the following terms (8 marks)
i. Inheritance
ii. Encapsulation
iii. Polymorphism
iv. Exception
b) Differentiate between: (6 Marks)
i. A while and a do while loop
ii. Superclass and subclass
iii. Conventional programming and event driven programming
c) Discuss in detail the following concepts as used in object oriented programming
i. Set()
ii. Get() (4 marks)
d) Describe the following terms citing examples for each (9 marks)
i. extends
ii. abstract
iii. super

e) Differentiate between method overriding and method overloading with example (4 marks)

f) Write a Java application that declares a class Person. It should have instance variables to record
name, age and salary. The variables should be of type String, integer and float. Create a Person
object to set and display the instance variables. (7 marks)

g) Differentiate between the following flow control statements, citing an example usage of each:
Exit and break (2 marks)
QUESTION 2 (15 MARKS)

a) Write an object oriented program in java that implements a class BankAccount with the
attributes; Ownername, AccountNumber and Balance and the methods; getBalance(),
Deposit() and Withdraw(), the program should then implement a class OverDraftAccount
with the attribute CreditLimit and inherits from the class BankAccount and overrides the
method withdraw by adding the account balance to the CreditLimit i.e
DispensableAmount = Balance + CreditLimit). (10 marks)

b) Java exception handling is managed by five keywords: state and discuss the role of each
of the keywords. (5 Marks)

QUESTION 3 (15 MARKS)

a) Use an if-else statement to write a program in Java that awards students grades based on
the following guidelines; A = 70-100, B = 60 – 69, C = 50-59, D = 40-49, F = 0-39. The
program should request the user to input the mark attained by the student, and should
return an invalid input error in case the user tries to input any value that is not in the
range 0-100. (5 marks)
b) Explain the lifecycle of an Applet (2 marks)
c) Write an Applet that displays “Hello World!” at the center of the Applet (8 marks)
QUESTION 4 (15 MARKS)

a) Write a program that accepts two strings as its arguments. It converts these to double
values and displays the sum. The program generates an error message if the format is
invalid or if there are no arguments. ( 10 marks)
b) Distinguish between Java applet and Java application (5marks)
QUESTION 5 (15 Marks)

a) Assume that the test results of a batch of students are stored in three different classes.
Create a class Student which store the roll number, a class Test which inherits class
Student and stores the marks obtained in three subjects, and class Result inherits class
Test which contains the total marks and percentage obtained in the test.
Include necessary methods to achieve the following tasks:
1. Calculate Total and Percentage
2. Display roll number, marks for three subjects, total and percentage
(10 marks)
b) Define a String and state FIVE methods used to manipulate Strings in Java.
(5 marks)

You might also like