Sample Examination Paper Programming and Software Development

Similar documents
Introduction to Programming Using Java (98-388)

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler so far

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End

The role of semantic analysis in a compiler

EXAMINATION INSTRUCTIONS

NATIONAL UNIVERSITY OF SINGAPORE

University of Utah School of Computing

Csci 102: Sample Exam

Midterm Exam CS 251, Intermediate Programming March 6, 2015

COMP 401 Spring 2013 Midterm 1

COM S 211/ENGRD 211 May 15, 2003

Java for Programmers Course (equivalent to SL 275) 36 Contact Hours

CONTENTS. Chapter 1 Getting Started with Java SE 6 1. Chapter 2 Exploring Variables, Data Types, Operators and Arrays 13

Midterm Exam CS 251, Intermediate Programming March 12, 2014

Objects and Iterators

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

Lab & Assignment 1. Lecture 3: ArrayList & Standard Java Graphics. Random Number Generator. Read Lab & Assignment Before Lab Wednesday!

+! Today. Lecture 3: ArrayList & Standard Java Graphics 1/26/14! n Reading. n Objectives. n Reminders. n Standard Java Graphics (on course webpage)

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

EXAMINATION INSTRUCTIONS

CS 180 Final Exam Review 12/(11, 12)/08

M257 Putting Java to work

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

(2½ hours) Total Marks: 75

Java Programming Lecture 6

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

COMP 401 Spring 2014 Midterm 1

Q1 Q2 Q3 Q4 Q5 Total 1 * 7 1 * 5 20 * * Final marks Marks First Question

Outline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring

Lab5. Wooseok Kim

CSCI 136 Written Exam #0 Fundamentals of Computer Science II Spring 2015

This exam is closed textbook(s) and closed notes. Use of any electronic device (e.g., for computing and/or communicating) is NOT permitted.

C++ (Non for C Programmer) (BT307) 40 Hours

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

Discover how to get up and running with the Java Development Environment and with the Eclipse IDE to create Java programs.

Final Exam CS 152, Computer Programming Fundamentals December 9, 2016

What are the characteristics of Object Oriented programming language?

Final Exam CS 251, Intermediate Programming December 10, 2014

COM S 213 PRELIM EXAMINATION #2 April 26, 2001

CSIS 10A PRACTICE FINAL EXAM Name Closed Book Closed Computer 3 Sheets of Notes Allowed

Java Review: Objects

CSI 1100 / 1500 Fall 2004 Introduction to Computer Science I Final Examination

Module Contact: Dr Gavin Cawley, CMP Copyright of the University of East Anglia Version 1

Java Collection Framework

1 Inheritance (8 minutes, 9 points)

: Intro Programming for Scientists and Engineers Final Exam

Final Exam. COMP Summer I June 26, points

JAVA MOCK TEST JAVA MOCK TEST III

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

UMBC CMSC 331 Final Exam

I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++

The Sun s Java Certification and its Possible Role in the Joint Teaching Material

CSE331 Winter 2014, Final Examination March 17, 2014 Please do not turn the page until 8:30. Rules:

About this exam review

Checked and Unchecked Exceptions in Java

September 10,

VALLIAMMAI ENGINEERING COLLEGE

Java Review. Fundamentals of Computer Science

Unit 1 Lesson 4. Introduction to Control Statements

CS 3360 Design and Implementation of Programming Languages. Exam 1

Enums. In this article from my free Java 8 course, I will talk about the enum. Enums are constant values that can never be changed.

CMSC 132: Object-Oriented Programming II

Problem Score Max Score 1 Syntax directed translation & type

Declarations and Access Control SCJP tips

Semantic Analysis. Lecture 9. February 7, 2018

Object Orientated Analysis and Design. Benjamin Kenwright

Exam Duration: 2hrs and 30min Software Design

UMBC CMSC 331 Final Exam Section 0101 December 17, 2002

Objects and Classes. 1 Creating Classes and Objects. CSCI-UA 101 Objects and Classes

Faculty of Science COMP-202A - Foundations of Computing (Fall 2013) - All Sections Midterm Examination

Computer Science II (20082) Week 1: Review and Inheritance

CIS 110 Introduction to Computer Programming 8 October 2013 Midterm

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger

Final Exam CS 152, Computer Programming Fundamentals May 9, 2014

Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

CSE 331 Final Exam 12/9/13

DHANALAKSHMI SRINIVASAN COLLEGE OF ENGINEERING AND TECHNOLOGY ACADEMIC YEAR (ODD SEM)

Object Oriented Programming. Solved MCQs - Part 2

CSIS 10B Lab 2 Bags and Stacks

Final Exam. Kenneth J. Goldman December 18, Name: Student ID Number: Signature:

Instantiation of Template class

University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ June Exam

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

CPSC 211, Sections : Data Structures and Implementations, Honors Final Exam May 4, 2001

Recitation 02/02/07 Defining Classes and Methods. Chapter 4

Part 3. Why do we need both of them? The object-oriented programming paradigm (OOP) Two kinds of object. Important Special Kinds of Member Function

CS 3331 Advanced Object-Oriented Programming Final Exam

FORM 2 (Please put your name and form # on the scantron!!!!)

Lecture 16: Static Semantics Overview 1

Computing Science 114 Solutions to Midterm Examination Tuesday October 19, In Questions 1 20, Circle EXACTLY ONE choice as the best answer

SEMESTER ONE EXAMINATIONS SOLUTIONS 2003/2004

CSE143 Exam with answers MIDTERM #1, 1/26/2001 Problem numbering may differ from the test as given.

Short Notes of CS201


Final Exam CS 152, Computer Programming Fundamentals December 5, 2014

The Compiler So Far. CSC 4181 Compiler Construction. Semantic Analysis. Beyond Syntax. Goals of a Semantic Analyzer.

Collections. Collections Collection types Collection wrappers Composite classes revisited Collection classes Hashtables Enumerations

Midterm Exam CS 251, Intermediate Programming October 8, 2014

CIS 341 Final Examination 4 May 2017

QUIZ. What is wrong with this code that uses default arguments?

Transcription:

THE UNIVERSITY OF MELBOURNE DEPARTMENT OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING Sample Examination Paper 2008 433-520 Programming and Software Development Exam Duration: 2 hours Total marks for this Exam: 60 Reading Time: 15 minutes This exam has 7 pages. Authorised materials: Writing materials (e.g. pens, pencils) and dictionaries are allowed. Books and calculators are not allowed. Instructions to Invigilators: Supply students with standard script book(s). The exam paper must remain in the exam room and be returned to the subject coordinator. Instructions to Students: Attempt all questions. Answer questions in the provided answer sheet and the script book(s). For multiple choice questions, chose the best answer and mark it in the provided answer sheet. Clearly number and write your answers. Any unreadable answer will be considered wrong. For short answer questions, write no more than three sentences. Use the marks as a guide to the level of details required in your answers while keeping your answers concise and relevant. This paper should not be reproduced and lodged with Baillieu Library. Page 1 of 7

Multiple choice questions: [1 mark each] 1. Java is an example of a(n) a) machine language b) assembly language c) high-level language d) fourth generation language e) all of the above 2. What does the following code output? DecimalFormat dfquestion = new DecimalFormat("#0.###E0"); System.out.println(dfQuestion.format(12.7896987)); a) 12.80E0 b) 12.79E0 c) 12.800E1 d) 1.28E2 e) 0.0128E3 3. If x is an int and y is a float, which of the following is an illegal assignment statement? a) y = x; b) x = y; c) y = (float) x; d) x = (int) y; e) all of the above are legal 4. To compare two strings lexicographically, which of the following String methods should be used? a) equals b) equalsignorecase c) compareto d) == e) all of the above 5. In order to declare a constant, you would use which of the following Java reserved words? a) private b) static c) int d) final e) class 6. If two variables contain aliases of the same object then a) The object may be modified using either alias b) The object cannot be modified unless there s but a single reference to it c) A third alias is created if/when the object is modified d) The object will become an orphan if both variables are set to null e) Answers (a) and (d) are correct Page 2 of 7

7. Say you write a program that has the following statement in it: Random rand; But you fail to include an import statement for java.util.random (or java.util.*). What will happen when you attempt to compile and run your program. a. The program won t run, but it will compile with a warning about the missing class. b. The program won t compile you ll receive a syntax error about the missing class. c. The program will compile, but you ll receive a warning about the missing class. d. The program will encounter a runtime error when it attempts to access any member of the Random class e. none of the above 8. Consider the following enumeration: enum Speed { FAST, MEDIUM, SLOW }; Which of the following statements is correct? a) The ordinal value of MEDIUM is 2 b) The ordinal value of SLOW is 3 c) The name of the Speed enumeration whose ordinal value is zero is FAST d) The name of the Speed enumeration whose ordinal value is one is SLOW e) None of the above 9. Given two String variables, s1 and s2, to determine if they are the same length, which of the following conditions would you use? a) (s1.equals(s2)) b) (s1.length( ).equals(s2)) c) (s1.length( ).equals(s2.length( )) d) (s1.length( ) == s2.length( )) e) length(s1) == length(s2) 10. The String class compareto method does which of the following: a) compares two string in a case-independent manner b) yields true or false c) yields 0 if the two strings are identical d) returns 1 if the first string comes lexically before the second string e) none of the above 11. What will be displayed by the following command: System.out.println(Math.pow(3, 3-1)); a) 9.0 b) 8.0 c) 6.0 d) 4.0 e) 27.0 Page 3 of 7

12. The relationship between classes and objects is best described as: a) classes are instances of objects b) objects are instances of classes c) objects and classes are the same thing d) classes are programs while objects are variables e) objects are the instance data of classes 13. A class constructor usually defines which of the following a) how an object is initialized b) how an object is interfaced c) the number of instance data in the class d) the number of methods in the class e) if the instance data are accessible outside of the object directly 14. Having multiple methods of the same name in a class where each method has a different number of or type of parameters is known as: a) encapsulation b) information hiding c) tokenizing d) importing e) method overloading 15. Consider a method defined with the header: public void foo(int a, int b). Which of the following method calls is legal? a) foo(0, 0.1); b) foo(0 / 1, 2 * 3); c) foo(0); d) foo( ); e) foo(1 + 2, 3 * 0.1); 16. Every Iterator has which of the following: a) a hasnext( ) method b) a hasfirst( ) method c) a hasnextint( ) method d) a isempty( ) method e) none of the above 17. The statement if (x < 0) y = x; else y = 0; can be rewritten using a conditional operator as a) y = (x < 0)? x : 0; b) x = (x < 0)? y : 0; c) (x < 0)? y = x : y = 0; d) y = (x < 0); e) y = if (x < 0) x : 0 Page 4 of 7

18. Consider the following paint method: public void paint(graphics page) { int x, y = 200; page.setcolor(color.blue); for (x = 100; x < 200; x += 20) page.fillrect(x, y, 10, y-x); } This paint method will draw several bars (sort of like a bar graph). How many bars will be displayed? a) 4 b) 5 c) 6 d) 10 e) 20 19. It is easier to correct errors found in a program if a) they are identified early in the development cycle b) they are identified during testing c) they are identified during program use d) they are identified during maintenance e) all of the above are equally true, errors are easily corrected in any of these stages 20. It is a bad programming habit to build an initial program and then spend a great deal of time modifying the code until it is acceptable. This is known as which of the following: a) the prototyping approach b) the waterfall model c) iterative development d) the recursive approach e) the build-and-fix approach 21. The idea that an object can exist separate from the executing program that creates it is called which of the following: a) transience b) static c) persistence d) serialization e) finality 22. In general, spending more time on a better design for a software will do which of the following: a) shorten testing time b) slightly reduce maintenance efforts c) slightly increase maintenance efforts d) greatly reduce maintenance efforts e) not alter the time it takes for any other stage whatsoever Page 5 of 7

23. Which of the following interfaces would be used to implement a class that represents a group of objects? a) Collection b) Speaker c) Comparable d) MouseListener e) KeyListener 24. Which of the following Layout Manager types would you use if you want GUI components to be placed at the North, South, East, West and Center of a container? a) FlowLayout b) BorderLayout c) BoxLayout d) GridLayout e) TabbedPane 25. Assume this statement: int[] values = {9,4,12,2,6,8,18}; Now the statement: System.out.println(values[7]); will do: a) output 7 b) output 18 c) output nothing d) cause an ArrayOutOfBoundsException to be thrown e) cause a syntax error Short answer questions: Answers for the following questions should not exceed three sentences. 26. What is a class variable? How is it defined in Java? [2 marks] 27. Explain how favoring composition over inheritance may improve Object- Oriented Design. [2 marks] 28. What is a wrapper class and when is it usually useful? Give an example of a standard wrapper class? [2 marks] 29. What is the main difference between applets and normal Java programs? Briefly explain. [2 marks] 30. Name all the visibility modifiers in Java. Which one is the preferred visibility for instance variables of a class? [2 marks] Page 6 of 7

Programming questions: 31. Write a code fragment that declares a two-dimensional 10x10 array of integers called myarray and then initialize each element of the array to have the value of i * j where i and j are the two indices of the element. For instance, the value for element myarray[5][3] must be set to 15 (i.e. 5 * 3). [5 marks] 32. Write an interface named XYInterface that contains two int constants, X = 5 and Y = 10 and a method called usexy which receives no parameters and returns an integer value. (You don t need to implement the XYInterfac) [5 marks] 33. String s1 is said to overlap String s2 if all of the characters in s1 also appear in s2 (in any order). Write a method called testoverlap that takes two strings (called s1 and s2) as input parameters and returns a boolean value that is true if s1 overlaps s2 and false otherwise. [5 marks] 34. Write a class called Employee. Each employee should have a name, an identification number, a position, and an hourly wage. a) Write a method that is passed the int value of the number of hours worked for the week as a parameter, and returns the pay for the Employee (including overtime, which is 1.5 * hourly wages for each hour over 40). [5 marks] b) Write a raise method that is passed an increase (or decrease) in hourly wages and updates the Employee s hourly wages appropriately. The amount passed is strictly the amount of increase or decrease, not a new hourly wages. If the amount of increase (or decrease) is more than what the Employee currently makes, do not adjust the hourly wage, but arise an exception called InvalidRaise. [5 marks] End of Sample Exam Page 7 of 7