BSc. (Hons.) Software Engineering. Examinations for / Semester 2

Similar documents
BSc (Hons) Computer Science with Network Security/ BSc (Hons) Software Engineering/ BSc (Hons) Web Technologies. Examinations for 2016 Semester 1

Object- Oriented Analysis, Design and Programming

Inheritance. Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question)

UNIVERSITI SAINS MALAYSIA. CIT502 Object-Oriented Programming and Software Engineering

EXAMINATION FOR THE BSC (HONS) INFORMATION TECHNOLOGY; BSC (HONS) INFORMATION SYSTEMS & BSC (HONS) COMPUTER SCIENCE; YEAR 1

Module Contact: Dr Taoyang Wu, CMP Copyright of the University of East Anglia Version 1

Module Contact: Dr Geoff McKeown, CMP Copyright of the University of East Anglia Version 1

I pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class.

University of Palestine. Mid Exam Total Grade: 100

BEng (Hons) Electronic Engineering. BEng (Hons) Telecommunications. Examinations for / Semester 2

1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4'

Full file at

Object-oriented basics. Object Class vs object Inheritance Overloading Interface

B2.52-R3: INTRODUCTION TO OBJECT ORIENTATED PROGRAMMING THROUGH JAVA

BEng (Hons) Telecommunications. Examinations for 2016 / Semester 2

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

Chapter 4 Loops. Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved.

Final Examination Semester 2 / Year 2010

Exam Duration: 2hrs and 30min Software Design

Islamic University of Gaza Faculty of Engineering Computer Engineering Department

CSC 1051 Algorithms and Data Structures I. Final Examination May 12, Name

Chapter 1: Introduction to Computers, Programs, and Java

Inheritance and Polymorphism

Birkbeck (University of London) Software and Programming 1 In-class Test Mar 2018

University of Cape Town ~ Department of Computer Science. Computer Science 1015F ~ 2007

Computer Science 1 Ah

8. Polymorphism and Inheritance

University of Cape Town ~ Department of Computer Science. Computer Science 1015F ~ 2007

More on Classes. 1 tostring

CS/B.TECH/CSE(OLD)/SEM-6/CS-605/2012 OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70

Questions Answer Key Questions Answer Key Questions Answer Key

Classes and Objects 3/28/2017. How can multiple methods within a Java class read and write the same variable?

University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ Test 2. Question Max Mark Internal External

1st Semester MTCE 601A COMPUTER SYSTEM SOFTWARE

CS 110 Practice Final Exam originally from Winter, Instructions: closed books, closed notes, open minds, 3 hour time limit.

CoSc Lab # 8 (an array of a class) Due Date: Part I, Experiment classtime, Tuesday, Dec 4 th, 2018.

Final Examination Semester 3 / Year 2012

Final Examination Semester 3 / Year 2007

Final Examination Semester 3 / Year 2012

Java Applets. Last Time. Java Applets. Java Applets. First Java Applet. Java Applets. v We created our first Java application

Class, Variable, Constructor, Object, Method Questions

HALF-YEARLY EXAMINATIONS FEBRUARY Subject: Computing Form: 4 Time: 1 ½ hours MARKING SCHEME

Functions. x y z. f (x, y, z) Take in input arguments (zero or more) Perform some computation - May have side-effects (such as drawing)

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

Using the Xcode Debugger

COMP200 - Object Oriented Programming: Test One Duration - 60 minutes

Java Object Oriented Design. CSC207 Fall 2014

A Foundation for Programming

CSE115 Introduction to Computer Science I Coding Exercise #7 Retrospective Fall 2017

Module Contact: Dr Geoff McKeown, CMP Copyright of the University of East Anglia Version 1

1.00 Lecture 14. Exercise: Plants

Chapter 5 Control Statements: Part 2 Section 5.2 Essentials of Counter-Controlled Repetition

The University of Nottingham

ECE 122. Engineering Problem Solving with Java

CSC 1051 Algorithms and Data Structures I. Final Examination May 12, Name: KEY. Question Value Score

CS 101 Fall 2006 Midterm 3 Name: ID:

BSc ( Hons) Computer Science with Network Security. Examinations for / Semester 2

BSc (Hons) Computer Science. with Network Security. Examinations for / Semester1

First Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 7 October 2010

P.G.D.C.M. (Semester II) Examination, :WEB TECHNOLOGY INCLUDING E-COMMERCE, HTML AND BASIC JAVA (2008 Pattern)

Inheritance CSC9Y4. Inheritance

Lecture 2: Java & Javadoc

COMPUTER APPLICATIONS

Object Oriented Software Development CIS Today: Object Oriented Analysis

CISC-124. Passing Parameters. A Java method cannot change the value of any of the arguments passed to its parameters.

ANSWER KEY First Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 7 October 2010

Object Oriented Programming is a programming method that combines: Advantage of Object Oriented Programming

Admin. CS 112 Introduction to Programming. Recap: OOP Analysis. Software Design and Reuse. Recap: OOP Analysis. Inheritance

Final Examination Semester 2 / Year 2012

Birkbeck (University of London) Software and Programming 1 In-class Test Mar Answer ALL Questions

Questions Answer Key Questions Answer Key Questions Answer Key

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade;

CS 1302 Chapter 9 (Review) Object & Classes

Fundamentals of Programming Data Types & Methods

Final Examination Semester 3 / Year 2010

Final Examination Semester 3 / Year 2008

Course Outline. Introduction to java

C212 Early Evaluation Exam Mon Feb Name: Please provide brief (common sense) justifications with your answers below.

BSc (Hons) Software Engineering. Examinations for / Semester 2

BEng. (Hons) Telecommunications. Examinations for / Semester 2

CSE 201 JAVA PROGRAMMING I. Copyright 2016 by Smart Coding School

2. Write a program to convert 69F into its equivalent centigrade temperature.

Practice Questions for Chapter 9

CPSC 219 Extra review and solutions

CS111: PROGRAMMING LANGUAGE II

CSCI-142 Exam 1 Review September 25, 2016 Presented by the RIT Computer Science Community

PROGRAMMING LANGUAGE 2

APCS Semester #1 Final Exam Practice Problems

Final Examination Semester 2 / Year 2011

BRA BIHAR UNIVERSITY, MUZAFFARPUR DIRECTORATE OF DISTANCE EDUCATION

Final Examination Semester 2 / Year 2012

B.Sc. (Hons.) Computer Science I B.Sc. (Hons.) Electronics. (i) Runtime polymorphism and compile time polymorphism

Practice Questions for Final Exam: Advanced Java Concepts + Additional Questions from Earlier Parts of the Course

CSIS 10A Practice Final Exam Solutions

Overriding המחלקה למדעי המחשב עזאם מרעי אוניברסיטת בן-גוריון

3. Convert 2E from hexadecimal to decimal. 4. Convert from binary to hexadecimal

Mutating Object State and Implementing Equality

CS260 Intro to Java & Android 03.Java Language Basics

University of Cape Town Department of Computer Science. Computer Science CSC115F. June 2003/2004 Supplementary Exam

Transcription:

BSc. (Hons.) Software Engineering Cohort: BSE/04/PT Examinations for 2005-2006 / Semester 2 MODULE: OBJECT ORIENTED PROGRAMMING MODULE CODE: BISE050 Duration: 2 Hours Reading Time: 5 Minutes Instructions to Candidates: 1. Answer all questions. 2. Questions may be answered in any order but your answers must show the question number clearly. 3. Always start a new question on a fresh page. 4. All questions do not equal marks. 5. Total marks 70. This question paper contains 3 questions and 6 pages. Page 1 of 6

ANSWER ALL QUESTIONS QUESTION 1: (25 MARKS) (a) Draw out a UML class diagram that captures the following information: An Employee is a kind of Person. An ATM is a kind of Machine. Both an Employee and an ATM can behave as if they were a Cashier, in that it is possible to both withdraw cash from them and deposit cash with them. (b) Now consider the Person class and the Cashier interface listed below. Write the Java code for an implementation of the Employee class of part 1(a). Do not complete the body of any methods in the Employee class - just place comments to outline the actions that should occur: public class Person { public int age; public int secid_number; public interface Cashier { public void withdraw(int account_id, int amount); public void deposit(int account_id, int amount); (c) The Java class for Person in part 1(b) does not illustrate best practice in Java programming. i. Modify the Person class to make it robust so that it is not possible for negative values of the fields of an instance of Person to be set. ii. Define a constructor for the Person class that enables an instance to be created with specific age and secid_number values. iii. Define a constructor for the Employee class that also enables specific age and secid_number values to be set. iv. What is the difference between declaring a field private and declaring it protected? Question 1: (continued) (6 marks) (Continued) Page 2 of 6

(d) We now want to be able to use the Person class in an application. i. What is the name that must be used for the method that defines the entry point to the application? ii. How should this method be declared? iii. How would you create an instance of a Person when using this method? iv. Write the Java code for a method that enables us to update the age of a Person. v. Name a Java package that could be used to avoid having to input and output data at a command prompt. (e) Write statements in Java for the following: i. to compare two strings s1 and s2 for equality; ii. to declare a useful constant Pi, whose value is 3.14159; iii. an array, equip, of 20 objects of type Equipment. (3 marks) (f) Consider the following statements int[] smallnumbers = {5, 6, 7, 8, 9, 10; int[] largenumbers = {510, 610, 710, 810, 910, 1010, 1110; System.arraycopy(smallNumbers, 2, largenumbers, 1, 3); for (int i = 0; i < largenumbers.length; i++) System.out.println(i + ": " + largenumbers[i]); What is the output after the code is executed? (2 marks) (g) Suppose we have created a Point class which has fields holding the x- and y-coordinates of a point in 2-dimensional space. Suppose we create an instance p of the Point class as follows: Point p = new Point(1.0, 2.0); We next write the following statement: Point q = p; Suppose now we assign the x co-ordinate of q the value 42.0: q.x = 42.0; What value is output when we execute the statement: System.out.println(p.x); (2 marks) Page 3 of 6

QUESTION 2: (25 MARKS) Vehicle -int numberofwheels +vehicle() #vehicle(int wheels) +int getnumberofwheels() +boolean hasengine() Car Bicycle MotorCycle Figure 1: A class hierarchy Consider the class hierarchy of vehicles shown in Figure 1, with the following additional information: Cars always have four wheels; Bicycles and their subclasses always have two wheels. Note: there are only default (i.e. parameter-less) constructors available to the clients of the hierarchy. (a) Convert the hierarchy of Figure 1 to Java. (7 marks) (b) For each of the following statements pertinent to classes of the hierarchy state whether they are true or false in Java and give a brief explanation why it is or it is not the case. i. Vehicle [] v1 = new Vehicle[3]; ii. Vehicle v2 = new Vehicle(); iii. Vehicle v3 = new MotorCycle(); iv. Car c1 = new Bicycle(); v. Bicycle b = new MotorCycle(); (2 marks each) (Continued) Page 4 of 6

Question 2: (continued) (c) Describe overriding and method overloading. Write some code to show an example. (d) An interface is a little like an abstract class that must be extended in exactly the manner that its abstract methods specify. Give two differences of an interface from an abstract class. Page 5 of 6

QUESTION 3: (20 MARKS) (a) The following is a simple example of a Java Class: // File: Welcome.java public class Welcome { public static void main(string args[]) { System.out.println( Welcome to Java World ); Convert this file into an applet that prints out the same message when it is executed on a web page. Ensure that the text is written at the pixel position (10, 10) from the top left corner of the applet window. (6 marks) (b) We can now call this applet from inside a web page. Suppose we wish to display the applet inside an applet window that is 200 pixels wide and 50 pixels high. What is the line of html code that needs to be inserted into an html file to do this? (2 marks) (c) Now modify the applet from Part 3(a) so that the text is written out with the following properties: Font is Arial, Bold; Font size is 26 point; Text colour is blue. (d) In Part 3(c), the text string and the font size have been hard-wired into the applet definition. However, we can pass both of these in to the applet as parameters. Modify the code you have written so far to enable both the text to be written on the screen, and the font size to be entered as parameters. (e) Now we can reuse the applet in a number of different web pages, and print out different strings in different sizes. Write down the html fragment that will enable the applet to be called, with parameter values for the text string and font size set as Aren t I clever!, and 18, respectively. ***END OF QUESTION PAPER*** Page 6 of 6