0% found this document useful (0 votes)
56 views3 pages

Exam Questions Set 2 CSC2106 Object-Oriented Design & Programming

Exam questions CSC2106 Object-Oriented Design & Programming at Catholic University Of Cameroon Bamenda

Uploaded by

Djamen
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
56 views3 pages

Exam Questions Set 2 CSC2106 Object-Oriented Design & Programming

Exam questions CSC2106 Object-Oriented Design & Programming at Catholic University Of Cameroon Bamenda

Uploaded by

Djamen
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 3

CATHOLIC UNIVERSITY OF CAMEROON (CATUC), BAMENDA

P.O. Box 782 Bamenda, Cameroon

FIRST SEMESTER EXAMINATION 2023/2024 SESSION

FACULTY OF SCIENCE DEPARTMENT: Computer Science


LECTURER: DJAMEN NYONKEU Gildas
COURSE TITLE: Object-Oriented Design & Programming
COURSE CODE : CSC2106 CREDIT VALUE: 6 DURATION : 3h

INSTRUCTIONS: Answer all questions

Section A General Knowledge (12 pts)


1. Describe the following characteristics concerning JAVA: Dynamic, robust, object
oriented.
2. What is a Class? Object?
3. Which class allows to create a windows in JAVA?
4. Enumerate the various types of layouts which can be created in JAVA
5. What is the role of new operator?
6. What is the difference between the classic Array and ArrayList in JAVA?
7. Which class allows to display a Table frame in Java?
8. To create a table frame, you need to implement a table model from an abstract class, give
the name of the abstract class and one method of such class.
Section B (14 pts)
1. (3 pts) Write Text‐Based Application using Object‐Oriented Approach to display your
name.
2. (5 pts) What are the values of the following variables?
(a) double var1 = 10 / 3;
(b) int var2 = (int) (2.5 * 2.6);
(c) boolean var3 = !(3 > 3);
(d) boolean var4 = (121 % 11 == 0) || (5 == 5);
(e)int var5 = 11 % 3;
3. (3 points) Declare a variable to hold the amount of money in your bank account and
initialize it to 245.25. Name your Java variable in a meaningful way so that any programmer
would know what value it holds. Your variable name should be at least two words.
4. (3 points) Give the return type and value of the following method calls on str (defined in
the above question).
(a) str.length()
(b) str.equalsIgnoreCase("HOW ARE YOU")
(c) str.indexOf("ou")
(d) str.lastIndexOf(" ")
(e) str.charAt(6)
(f) str.substring(1, 6)
Section C ( 8 pts):
1) Explain characteristics of Object-Oriented Programming.
2) Write a program to find average of all the numbers stored in an array.
3) What is ‘this’ and what are different uses of it? Explain with example.
4) Compare and contrast abstract class and interface.
Section D: GUI- in JAVA (7 pts )
Write a Swing application called SwingAdder as shown. The "ADD" button adds the two integers and display the
result. The "CLEAR" button shall clear all the text fields.

Hints: Set the content-pane to 4x2 GridLayout. The components are added from left-to-right, top-to-bottom.

Section E: (6 pts)
import java.io.*;
public class Employee {

// salary variable is a private static variable


private static double salary;

// DEPARTMENT is a constant
public static final String DEPARTMENT = "Development ";
int S = 0;
public static void main(String args[]) {
salary = 1000;
for (int i= 0; i<10 ; i= i+2) {
S += i;
}
System.out.println(DEPARTMENT + "average salary:" + salary);
}

1. What are the values of S and i at the end of the loop?


2. What are the meanings of the keywords private, public and static used in this code?
3. What are the attributes and methods of this JAVA class?
4. Declare the default constructor for this class.
Section F: (13 marks)
Consider the following class hierarchy where Class Car is the supper class and the classes ClassicCar and
SportCar are two subclasses derived from Car.
Class CarExhibition contains a filed of type ArrayList that stores objects of type Car.
(a) Class Car is an abstract class. Explain the role of an abstract class. [1 marks]
(b) Write a Java version of class Car assuming it has this constructor:
public Car(double price, int year)
and that the method calculateSalePrice ( ) is abstract. [3 marks]
(c) Write a Java version of class ClassicCar assuming it has this constructor:
public ClassicCar (double price, int year) [2 marks]
and that the method calculateSalePrice ( ) returns 10,000 as the sale price of the car.
d) Write a Java version of class SportCar assuming it has this constructor:
public SportCar(double price, int year) [3 marks]
and that the method calculateSalePrice ( ) calculates the sale price of the car as follow:
if year > 2000 then the sale price is 0.75 * its original price; if year > 1995 then the sale price
is 0.5 * its original price; otherwise the sale price is 0.25 * its original price
e) Write a Java version of class CarExhibition assuming it has this constructor:
public CarExhibition( ) [4 marks]
where CarExhibition has cars of different types stored in an arraylist and getTotalPrice method that
returns the total prices of all cars in the exhibition.

You might also like