Final Examination Semester 3 / Year 2008

Similar documents
Final Examination Semester 2 / Year 2011

Final Examination Semester 2 / Year 2011

Final Examination Semester 2 / Year 2010

Final Examination Semester 2 / Year 2012

Final Examination Semester 3 / Year 2010

Final Examination Semester 3 / Year 2010

Final Examination Semester 3 / Year 2007

Final Examination Semester 1 / Year 2011

Final Examination Semester 3 / Year 2008

Final Examination Semester 3 / Year 2010

CS 113 PRACTICE FINAL

Final Examination Semester 2 / Year 2010

Final Examination Semester 2 / Year 2011

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

Final Examination Semester 2 / Year 2010

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

Final Examination Semester 3 / Year 2012

Final Examination Semester 2 / Year 2012

CMP-326 Exam 2 Spring 2018 Total 120 Points Version 1

Final Examination Semester 3 / Year 2012

CS 113 MIDTERM EXAM 2 SPRING 2013

Overview. Lecture 7: Inheritance and GUIs. Inheritance. Example 9/30/2008

Final Examination Semester 2 / Year 2005

CS 116 Week 8 Page 1

More on Exception Handling

Islamic University of Gaza Faculty of Engineering Computer Engineering Department

Fundamentals of Object Oriented Programming

More on Exception Handling

Full download all chapters instantly please go to Solutions Manual, Test Bank site: testbanklive.com

Midterm assessment - MAKEUP Fall 2010

Final Examination Semester 1 / Year 2008

Full file at Chapter 2 - Inheritance and Exception Handling

UNIVERSITI TEKNOLOGI MALAYSIA FINAL EXAMINATION SEMESTER II, 2016 / 2017

Final Examination Semester 3 / Year 2012

Prelim 1 SOLUTION. CS 2110, September 29, 2016, 7:30 PM Total Question Name Loop invariants. Recursion OO Short answer

This exam is open book. Each question is worth 3 points.

Programming II (CS300)

PART1: Choose the correct answer and write it on the answer sheet:

SAMPLE EXAM Second Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 11 November 2010

CS 209 Programming in Java #10 Exception Handling

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

Programming II (CS300)

Arrays Classes & Methods, Inheritance

Southern College Kolej Selatan 南方学院. Final Examination Semester 1 / Year 2011

The Islamic University Gaza Department of Electrical & Computer Engineering. Midterm Exam Spring 2012 Computer Programming II (Java) ECOM 2324

09/08/2017 CS2530 INTERMEDIATE COMPUTING 9/8/2017 FALL 2017 MICHAEL J. HOLMES UNIVERSITY OF NORTHERN IOWA TODAY S TOPIC: Exceptions and enumerations.

Object-Oriented Concepts

C16b: Exception Handling

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

Recitation 3. 2D Arrays, Exceptions

CS 101 Exam 1 Spring 200 Id Name

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

Le L c e t c ur u e e 5 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Exception Handling

Exceptions Handeling

1.00 Lecture 13. Inheritance

Exam Duration: 2hrs and 30min Software Design

School of Informatics, University of Edinburgh

Swing - JTextField. Adding a text field to the main window (with tooltips and all)

CIS265 - Spring Exam 2 First Name Last Name CSU#


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

The University of Melbourne Department of Computer Science and Software Engineering Software Design Semester 2, 2003

COE318 Lecture Notes Week 10 (Nov 7, 2011)

Name:... ID:... class A { public A() { System.out.println( "The default constructor of A is invoked"); } }

RAIK 183H Examination 2 Solution. November 11, 2013

Prelim 1. CS 2110, September 29, 2016, 7:30 PM Total Question Name Loop invariants

CISC 3115 Modern Programming Techniques Spring 2018 Section TY3 Exam 2 Solutions

CH. 2 OBJECT-ORIENTED PROGRAMMING

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)

CSE 143 Lecture 25. I/O Streams; Exceptions; Inheritance. read 9.3, 6.4. slides adapted from Marty Stepp

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

Chapter 8. Exception Handling. CS 180 Sunil Prabhakar Department of Computer Science Purdue University

Fall CS 101: Test 2 Name UVA ID. Grading. Page 1 / 4. Page3 / 20. Page 4 / 13. Page 5 / 10. Page 6 / 26. Page 7 / 17.

Chapter 12 Exception Handling

Language Features. 1. The primitive types int, double, and boolean are part of the AP

Prelim 1. CS 2110, October 1, 2015, 5:30 PM Total Question Name True Short Testing Strings Recursion

CSE 143 Lecture 21. I/O Streams; Exceptions; Inheritance. read 9.3, 6.4. slides created by Marty Stepp

CSE 143 Lecture 22. I/O Streams; Exceptions; Inheritance. read 9.3, 6.4. slides created by Marty Stepp

CS101 Part 2: Practice Questions Algorithms on Arrays, Classes and Objects, String Class, Stack Class

AP CS Unit 6: Inheritance Notes

Instruction to students:

What can go wrong in a Java program while running?

if (x == 0); System.out.println( x=0 ); if (x = 0) System.out.println( x=0 );

More on Objects in JAVA TM

Prelim 1. CS 2110, March 15, 2016, 5:30 PM Total Question Name True False. Short Answer

Object- Oriented Analysis, Design and Programming

Session 04 - Object-Oriented Programming 1 Self-Assessment

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

CS 11 java track: lecture 3

Exception Examples. All examples written by Edith Hemaspaandra and modified by Jessica Bayliss

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

Abstract Classes. Abstract Classes a and Interfaces. Class Shape Hierarchy. Problem AND Requirements. Abstract Classes.

CS Internet programming Unit- I Part - A 1 Define Java. 2. What is a Class? 3. What is an Object? 4. What is an Instance?

First Name: AITI 2004: Exam 2 July 19, 2004

Tutorial 8 Date: 15/04/2014

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

F I N A L E X A M I N A T I O N

Java for Non Majors Spring 2018

Create a Java project named week10

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

Transcription:

Southern College Kolej Selatan 南方学院 Final Examination Semester 3 / Year 2008 COURSE : JAVA PROGRAMMING COURSE CODE : PROG1114 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE CLASS : CS08-A + CS08-B LECTURER : SO YONG QUAY Student s ID: Batch No: Notes to candidates: 1) The question paper consists of 6 pages and 13 questions. 2) There are three sections in this question paper; the students are required to answer all the questions. 3) Return the question paper with your answer booklet and disk.

Section I: Multiple Choices Questions (2% each) 1. Suppose s1 and s2 are two strings. Which of the following statements or expressions are incorrect? a. String s = new String("new string"); b. String s3 = s1 + s2; c. String s3 = s1.concat(s2); d. s1 >= s2 e. int i = s1.length(); 2. A subclass inherits from its superclasses. a. private data b. protected data c. public data d. a and c e. b and c 3. Suppose s1 and s2 are two strings. Which of the following statements or expressions are incorrect? a. String s3 = s1 - s2; b. int i = s1.compareto(s2); c. char c = s1[0]; d. char c = s1.charat(s1.length() - 1); e. a and c. 4. Suppose you want to display a text in multiple lines, which component should you use? a. JButton b. JLabel c. JTextField d. JTextArea 5. describes the state of an object. a. attributes b. methods c. constructors d. no of the above 1 / 6

Section II: Show the output of the program (2% each) 6. Show the output of the following program. public class C { Object[] o = {new A(), new B(); System.out.print(o[0]); System.out.print(o[1]); class A extends B { public String tostring() { return "A"; class B { public String tostring() { return "B"; 7. What is displayed on the console when the following program is run? class Test { try { System.out.println("Welcome to Java"); int i = 0; int y = 2 / i; System.out.println("Welcome to HTML"); finally { System.out.println("The finally clause is executed"); System.out.println("End of the block"); 2 / 6

8. Show the output of the following program: class A { public A() { System.out.println("The default constructor of A is invoked"); class B extends A { public B() { System.out.println("The default constructor of B is invoked"); public class C { B b = new B(); 9. What is the printout of the following code? public class FE200703_12 { public static void main(string[] args){ try { int value = 50; if (value < 40) throw new Exception ("Value is too small"); catch(exception ex){ System.out.println(ex.getMessage()); System.out.println("Continue after the catch block"); What would be the printout if the line int value = 50; is changed to int value =30; 3 / 6

10. What is displayed when the following program is run? class Test { try { System.out.println("Welcome to Java"); int[] a = new int[10]; a[0] = 1; System.out.println("Welcome to HTML"); finally { System.out.println("The finally clause is executed"); 4 / 6

Section III: Complete the program 11. Write programs to perform add, subtract, multiply, and divide operations. (See the following figure.) The user enters two numbers in the text fields, Number1 and Number 2, and display the result in Result text field when the Add, Subtract, Multiply or Divide button is clicked. If Number 1 or Number 2 were not an integer, the program would throw a NumberFormatException. If Number 2 were zero and the user press the Divide button, the program would throw an ArithmeticException (DivideByZeroException). Display the exception in a message dialog box, as shown in following figure. (35%) 12. Write a program to read from the file Text.txt that replaces a string in a text file with a new string and saves the change into a new file New.txt. Your program also needs to prompt the user to enter two string, old string and new string. (20%) 5 / 6

13. Design a class named MyPoint to represent a point with x and y-coordinates. The class contains: (25%) Two data fields x and y that represent the coordinates. A no-arg constructor that creates a point (0, 0). A constructor that constructs a point with specified coordinates. Two get methods for data fields x and y, respectively. A method named distance that returns the distance from this point to another point of the MyPoint type. A method named distance that returns the distance from this point to another point with specified x and y-coordinates. Implement the class and write a test program that creates two points (0, 0) and (10, 30.5) and displays the distance between them. 000 6 / 6