Department of Civil and Environmental Engineering, Spring Semester, ENCE 688R: Midterm Exam: 1 1/2 Hours, Open Book and Open Notes
|
|
- Mabel Byrd
- 5 years ago
- Views:
Transcription
1 Department of Civil and Environmental Engineering, Spring Semester, 2013 ENCE 688R: Midterm Exam: 1 1/2 Hours, Open Book and Open Notes Name : Question Points Score Total 100 1
2 Question 1: 30 points This question is about the principles of object-oriented program development and the basics of Java. [1a] (5 pts). Draw and label a diagram that shows the three types of relationships that can exist between classes. [1b] (5 pts). How would you extend the class hierarchy Figure 1. : Inheritance in modeling of a structure to represent a large building that contains a foot-bridge? (Just draw your solution on Figure 1). 2
3 Now let s consider the fragment of code: 1 public static final int NoElements = 10; 2 int [] idata = new int[ NoElements ]; 3 4 int ii = 0; 5 while ( ii < NoElements ) { 6 idata [ ii ] = 2*ii; 6 System.out.printf( "ii = %2d\n", ii ); 7 8 if ( ii <= 7 ) { 9 ii = ii + 2; 10 else { 11 ii = ii + 3; [1c] (3 pts). What does code on line 1 do? [1d] (3 pts). What does code on line 2 do? [1e] (5 pts). Construct a table showing the Loop No, value of ii, ii < NoElements, the program output, ii <= 7, and ii = ii + 2 and/or ii = ii + 3 in the looping construct: 3
4 [1f] (2 pts). What is the value of ii when the program execution reaches line 14 of the script? [1g] (3 pts). Draw and label a diagram showing the layout of memory for idata and its element values when the program reaches line 14. [1h] (2 pts). Briefly explain why Java is both a compiled language and an interpreted language? [1i] (2 pts). What is the purpose of the method main() in a Java application program? 4
5 Question 2: 30 points This question is about Java s mechanisms for programming by extension. We begin with the class Circle, which defines circles by their radius and (x,y) co-ordinates of the center, and then develop a second class, ColoredCircle, for Colored cirles. The details of class Circle are as follows: source code /* * ================================================================= * Circle(): This class defines circles. * ================================================================= */ import java.lang.math.*; public class Circle { double dx, dy, dradius; // Constructor public Circle() { public Circle( double dx, double dy, double dradius ) { this.dx = dx; this.dy = dy; this.dradius = dradius; // Compute the circle area... public double Area() { return Math.PI*dRadius*dRadius; // Copy circle parameters to a string format... public String tostring() { return "(x,y) = (" + dx + "," + dy + "): Radius = " + dradius; // Exercise methods in class Circle... public static void main( String [] args ) { System.out.println("Exercise methods in class Circle"); System.out.println("================================"); Circle ca = new Circle( 1.0, 2.0, 3.0 ); System.out.println("Circle ca : " + ca.tostring() ); System.out.println("Circle ca : Area = " + ca.area() ); 5
6 And the details of class ColoredCircle are as follows: source code /* * ================================================================= * coloredcircle(): This class defines colored circles. * ================================================================= */ import java.awt.color; public class ColoredCircle extends Circle { private Color color; // Constructor methods public ColoredCircle() { super(); this.color = Color.red; public ColoredCircle( double dx, double dy, double dradius, Color color ) { super(); this.dx = dx; this.dy = dy; this.dradius = dradius; this.color = color; // Retrieve colors... public String getcolors() { return "Color (r,g,b) = (" + color.getred() + "," + color.getgreen() + "," + color.getblue() + ")"; // =============================================== // Exercise methods in class ColoredCircle()... // =============================================== public static void main( String [] args ) { System.out.println("Exercise methods in class ColoredCircle"); System.out.println("======================================="); // Create, initialize, and print circle "ca"... ColoredCircle ca = new ColoredCircle( 1.0, 2.0, 3.0, Color.blue ); ca.dx = 1.0; 6
7 ca.dy = 2.0; ca.dradius = 3.0; ca.color = Color.blue; System.out.println( "Circle ca:" + ca.tostring() ); System.out.println( ca.getcolors() ); // Create, initialize, and print circle "cb"... ColoredCircle cb = new ColoredCircle( 1.0, 2.0, 3.0, Color.orange ); System.out.println( "Circle cb:" + cb.tostring() ); System.out.println( cb.getcolors() ); The program input/output generated by main() in Circle is: prompt >> java Circle Exercise methods in class Circle ================================ Circle ca : (x,y) = (1.0,2.0): Radius = 3.0 Circle ca : Area = prompt >> And the program output generated by main() in ColoredCircle is: prompt >> java ColoredCircle Exercise methods in class ColoredCircle ======================================= (x,y) = (1.0,2.0): Radius = 3.0 Color (r,g,b) = (0,0,255) (x,y) = (1.0,2.0): Radius = 3.0 Color (r,g,b) = (255,200,0) prompt >> Please examine the source code carefully and answer the following questions. [2a] (2 pts). Draw and label a schematic showing the relationship between the classes Circle and ColoredCircle. 7
8 [2b] (3 pts). List the variables and methods contained within the class Circle. [2c] (2 pts). What is the purpose of the line import java.lang.math.*; in Circle.java? And why is it needed by this program? [2d] (3 pts). Suppose that the line: Circle ca = new Circle( 1.0, 2.0, 3.0 ); in method main() of Circle is replaced by: Circle ca = new Circle( ); How would you modify the source code so that the overall functionality of main() remains unchanged? 8
9 [2e] (3 pts). How would you modify Circle.java so that the circle area is printed to three decimal places of accuracy (i.e., Circle ca: Area = ). [2f] (3 pts). List the variables and methods defined in the source code for ColoredCircle [2g] (3 pts). List the variables and methods available to ColoredCircle via inheritance mechanisms from Circle 9
10 [2h] (3 pts). What is the purpose of each term in: public class ColoredCircle extends Circle { [2i] (2 pts). What is the purpose of the method call super() in public ColoredCircle() { super(); this.color = Color.red; Suppose that Circle.java and ColoredCircle.java are located in the same directory (with no other files present). [2j] (3 pts). List the files that will exist in the directory before and after the compilation command: prompt >> javac Circle.java [2k] (3 pts). Now suppose that all of the bytecode files in Part 2j are deleted. List the files that will exist in the directory before and after the compilation command: prompt >> javac ColoredCircle.java 10
11 Question 3: 40 points This question covers Java Programming with abstract classes and array lists. Absract class Shape Location Rectangle Circle Triangle Figure 2. Relationship among the classes Shape, Location, Rectangle, Circle and Triangle. Figure 2 shows the relationship among the classes Shape, Location, Rectangle, Circle and Triangle. The following code is a snapshot of the actual implementation that only covers Shape.java, Location.java, Rectangle.java and the test program defined in EngineeringProperties.java. Shape.java. The details of Shape.java are as follows: public abstract class Shape { Location c = new Location(); public abstract double getx(); public abstract double gety(); public abstract String tostring(); public abstract double perimeter(); public abstract double area(); Location.java. The (x,y) coordinates of a point are handled in Location.java. public class Location { double dx, dy; Rectangle.java. The details of Rectangle.java are as follows: public class Rectangle extends Shape { double dside1, dside2; public Rectangle ( double dside1, double dside2, double dx, double dy ) { this.dside1 = dside1; 11
12 this.dside2 = dside2; c.dx = dx; c.dy = dy; public String tostring() { return "Rectangle : Side1 = " + dside1 + " Side2 = " + dside2 ; public double perimeter() { return 2.0*(dSide1 + dside2); public double area() { return dside1*dside2; public double getx() { return c.dx; public double gety() { return c.dy; EngineeringProperties.java. import java.util.arraylist; import java.util.iterator; import java.util.list; public class EngineeringProperties { public static void main ( String args[] ) { // Create and initialize a grid of ten shapes List shapes = new ArrayList(); Shape s0 = new Rectangle( 0.25, 0.25, 0.0, 2.0 ); Shape s1 = new Rectangle( 0.25, 0.25, 1.0, 1.0 ); // Add shapes to the array list... shapes.add( s0 ); shapes.add( s1 ); // Compute and print total shape area... double darea = 0.0; for (int ii = 1; ii <= shapes.size(); ii = ii + 1) { Shape s = (Shape) shapes.get(ii-1); darea = darea + s.area(); System.out.println(""); System.out.printf("Total Area = %10.2f\n", darea ); 12
13 System.out.println(" "); Please look at the source code carefully and answer the questions that follow: [3a] (5 pts). Write a main() method for Rectangle.java. The method should allocate and initialize an object of type Rectangle and then print its contents. Now suppose that the new version of Rectangle.java (containing your main() method) is compiled without error. [3b] (3 pts). What command would you give to run the Rectangle program? (Please do not write: I d press the run button). [3c] (3 pts). What will the program output look like? 13
14 [3d] (5 pts). Draw and label a diagram showing the layout of memory produced by the statement: Rectangle ra = new Rectangle( 1.0, 1.0, 3.0, 4.0 ); Note: Make sure that you capture the relationship between Rectangle, Shape and Location. [3e] (4 pts). What is the purpose of the method tostring() in the statement? System.out.println( ra.tostring() ); 14
15 Now let s move onto Shape.java. [3f] (5 pts). List two ways in which an abstract class (e.g., Shape.java) differs from a regular class (e.g., Circle.java). [3g] (5 pts). Draw and label a diagram showing the layout of memory that occurs after the block of statements: List shapes = new ArrayList(); Shape s0 = new Rectangle( 0.25, 0.25, 0.0, 2.0 ); Shape s1 = new Rectangle( 0.25, 0.25, 1.0, 1.0 ); shapes.add( s0 ); shapes.add( s1 ); has finished. 15
16 [3h] (5 pts). The block of code: double darea = 0.0; for (int ii = 1; ii <= shapes.size(); ii = ii + 1) { Shape s = (Shape) shapes.get(ii-1); darea = darea + s.area(); walks along the arraylist and computes total area of the shapes. Construct a simple table to show the value of darea as a function of variable ii. [3i] (5 pts). Briefly indicated how you would modify the body of main() to take advantage of Java Generics. 16
Department of Civil and Environmental Engineering, Spring Semester, ENCE 688R: Midterm Exam: 1 1/2 Hours, Open Book and Open Notes
Department of Civil and Environmental Engineering, Spring Semester, 2012 ENCE 688R: Midterm Exam: 1 1/2 Hours, Open Book and Open Notes Name : Question Points Score 1 30 2 50 Total 80 1 Question 1: 30
More informationDepartment of Civil and Environmental Engineering, Spring Semester, ENCE 688R: Midterm Exam: 1 1/2 Hours, Open Book and Open Notes
Department of Civil and Environmental Engineering, Spring Semester, 2016 ENCE 688R: Midterm Exam: 1 1/2 Hours, Open Book and Open Notes Name : Question Points Score 1 30 2 40 3 30 Total 100 1 Question
More informationWorking with Objects and Classes
p. 1/6 ENCE 688R Civil Information Systems Working with Objects and Classes Mark Austin E-mail: austin@isr.umd.edu Department of Civil and Environmental Engineering, University of Maryland, College Park
More informationDepartment of Civil and Environmental Engineering, Spring Semester, ENCE 688R: Final Exam: 2 Hours, Open Book and Open Notes
Department of Civil and Environmental Engineering, Spring Semester, 2017 ENCE 688R: Final Exam: 2 Hours, Open Book and Open Notes Name : Question Points Score 1 50 2 30 3 20 Total 100 1 Question 1: 50
More informationEngineering Software Development in Java
Engineering Software Development in Java Lecture Notes for ENCE 688R, Civil Information Systems Spring Semester, 2016 Mark Austin, Department of Civil and Enviromental Engineering, University of Maryland,
More informationDepartment of Civil and Environmental Engineering, Spring Semester, ENCE 688R: Final Exam: 2 Hours, Open Book and Open Notes
Department of Civil and Environmental Engineering, Spring Semester, 2016 ENCE 688R: Final Exam: 2 Hours, Open Book and Open Notes Name : Question Points Score 1 100 Total 100 1 Question 1: 100 points Let
More informationPractice Midterm 1. Problem Points Score TOTAL 50
CS 120 Software Design I Spring 2019 Practice Midterm 1 University of Wisconsin - La Crosse February 25 NAME: Do not turn the page until instructed to do so. This booklet contains 10 pages including the
More informationAbstract Classes. Abstract Classes a and Interfaces. Class Shape Hierarchy. Problem AND Requirements. Abstract Classes.
a and Interfaces Class Shape Hierarchy Consider the following class hierarchy Shape Circle Square Problem AND Requirements Suppose that in order to exploit polymorphism, we specify that 2-D objects must
More informationHomework 6. Yuji Shimojo CMSC 330. Instructor: Prof. Reginald Y. Haseltine
Homework 6 Yuji Shimojo CMSC 330 Instructor: Prof. Reginald Y. Haseltine July 21, 2013 Question 1 What is the output of the following C++ program? #include #include using namespace
More informationProblem 8.1: Model rectangles with Vertices...
------------------------------------------------------------------------- ENCE 688R: Solutions to Homework 2 March 2016 ------------------------------------------------------------------------- -------------------------------------------------------------------------
More informationThe Nervous Shapes Example
The Nervous Shapes Example This Example is taken from Dr. King s Java book 1 11.6 Abstract Classes Some classes are purely artificial, created solely so that subclasses can take advantage of inheritance.
More informationCSE 8B Programming Assignments Spring Programming: You will have 5 files all should be located in a dir. named PA3:
PROGRAMMING ASSIGNMENT 3: Read Savitch: Chapter 7 Programming: You will have 5 files all should be located in a dir. named PA3: ShapeP3.java PointP3.java CircleP3.java RectangleP3.java TriangleP3.java
More informationUniversity of Cape Town ~ Department of Computer Science Computer Science 1015F ~ June Exam
Name: Please fill in your Student Number and Name. Student Number : Student Number: University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ 2009 June Exam Question Max Internal
More informationFirst Name: AITI 2004: Exam 2 July 19, 2004
First Name: AITI 2004: Exam 2 July 19, 2004 Last Name: JSP Track Read Instructions Carefully! This is a 3 hour closed book exam. No calculators are allowed. Please write clearly if we cannot understand
More informationCS 110 Practice Final Exam originally from Winter, Instructions: closed books, closed notes, open minds, 3 hour time limit.
Name CS 110 Practice Final Exam originally from Winter, 2003 Instructions: closed books, closed notes, open minds, 3 hour time limit. There are 4 sections for a total of 49 points. Part I: Basic Concepts,
More informationF I N A L E X A M I N A T I O N
Faculty Of Computer Studies M257 Putting Java to Work F I N A L E X A M I N A T I O N Number of Exam Pages: (including this cover sheet( Spring 2011 April 4, 2011 ( 5 ) Time Allowed: ( 1.5 ) Hours Student
More informationDesign Patterns - Decorator Pattern
Design Patterns - Decorator Pattern Decorator pattern allows a user to add new functionality to an existing object without altering its structure. This type of design pattern comes under structural pattern
More informationJava Object Oriented Design. CSC207 Fall 2014
Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code
More information1.124J Foundations of Software Engineering. Problem Set 5. Due Date: Tuesday 10/24/00
1.124J Foundations of Software Engineering Problem Set 5 Due Date: Tuesday 10/24/00 Reference Readings: From Java Tutorial Getting Started: Lessons 1-3 Learning the Java Language: Lessons 4-7 o 4. Object-Oriented
More informationChapter 9 - Object-Oriented Programming: Polymorphism
Chapter 9 - Object-Oriented Programming: Polymorphism Polymorphism Program in the general Introduction Treat objects in same class hierarchy as if all superclass Abstract class Common functionality Makes
More information22. Inheritance. Java. Summer 2008 Instructor: Dr. Masoud Yaghini
22. Inheritance Java Summer 2008 Instructor: Dr. Masoud Yaghini Outline Superclasses and Subclasses Using the super Keyword Overriding Methods The Object Class References Inheritance Object-oriented programming
More information24. Inheritance. Java. Fall 2009 Instructor: Dr. Masoud Yaghini
24. Inheritance Java Fall 2009 Instructor: Dr. Masoud Yaghini Outline Superclasses and Subclasses Using the super Keyword Overriding Methods The Object Class References Superclasses and Subclasses Inheritance
More informationMACS 261J Final Exam. Question: Total Points: Score:
MACS 261J Final Exam May 5, 2008 Name: Question: 1 2 3 4 5 6 7 8 9 Total Points: 15 10 15 5 10 5 20 8 12 100 Score: Question 1............................................................. (15 points) (a)
More informationCS250 Intro to CS II. Spring CS250 - Intro to CS II 1
CS250 Intro to CS II Spring 2017 CS250 - Intro to CS II 1 Topics Virtual Functions Pure Virtual Functions Abstract Classes Concrete Classes Binding Time, Static Binding, Dynamic Binding Overriding vs Redefining
More informationPractice Midterm 1 Answer Key
CS 120 Software Design I Fall 2018 Practice Midterm 1 Answer Key University of Wisconsin - La Crosse Due Date: October 5 NAME: Do not turn the page until instructed to do so. This booklet contains 10 pages
More informationCSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)
Name: Email address: Quiz Section: CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We will
More information1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4'
Practice questions: 1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4' 2. Will System.out.println((char)4) display 4? a. Yes b. No 3. The expression "Java
More informationFirst Name: AITI 2004: Exam 2 July 19, 2004
First Name: AITI 2004: Exam 2 July 19, 2004 Last Name: Standard Track Read Instructions Carefully! This is a 3 hour closed book exam. No calculators are allowed. Please write clearly if we cannot understand
More informationCMSC 433 Section 0101 Fall 2012 Midterm Exam #1
Name: CMSC 433 Section 0101 Fall 2012 Midterm Exam #1 Directions: Test is closed book, closed notes. Answer every question; write solutions in spaces provided. Use backs of pages for scratch work. Good
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 26 March 26, 2015 Inheritance and Dynamic Dispatch Chapter 24 public interface Displaceable { public int getx(); public int gety(); public void move
More informationMidterm Examination (MTA)
M105: Introduction to Programming with Java Midterm Examination (MTA) Spring 2013 / 2014 Question One: [6 marks] Choose the correct answer and write it on the external answer booklet. 1. Compilers and
More informationCISC 3115 TY3. C09a: Inheritance. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 9/20/2018 CUNY Brooklyn College
CISC 3115 TY3 C09a: Inheritance Hui Chen Department of Computer & Information Science CUNY Brooklyn College 9/20/2018 CUNY Brooklyn College 1 Outline Inheritance Superclass/supertype, subclass/subtype
More informationCSE 143 Au04 Midterm 1 Page 1 of 9
CSE 143 Au04 Midterm 1 Page 1 of 9 Question 1. (4 points) When we re modifying Java code, some of the things we do will change the coupling between the class we re working on and other classes that it
More informationCS170 Introduction to Computer Science Midterm 2
CS170 Introduction to Computer Science Midterm 2 03/25/2009 Name: Solution You are to honor the Emory Honor Code. This is a closed book and closednotes exam, and you are not to use any other resource than
More informationIntroduction to OOP with Java. Instructor: AbuKhleif, Mohammad Noor Sep 2017
Introduction to OOP with Java Instructor: AbuKhleif, Mohammad Noor Sep 2017 Lecture 11: Inheritance and Polymorphism Part 1 Instructor: AbuKhleif, Mohammad Noor Sep 2017 Instructor AbuKhleif, Mohammad
More informationCS 101 Exam 2 Spring Id Name
CS 101 Exam 2 Spring 2005 Email Id Name This exam is open text book and closed notes. Different questions have different points associated with them. Because your goal is to maximize your number of points,
More informationCISC 3115 Modern Programming Techniques Spring 2018 Section TY3 Exam 2 Solutions
Name CISC 3115 Modern Programming Techniques Spring 2018 Section TY3 Exam 2 Solutions 1. a. (25 points) A rational number is a number that can be represented by a pair of integers a numerator and a denominator.
More informationITI Introduction to Computing II
ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 20, 2014 Abstract
More informationChapter 14 Abstract Classes and Interfaces
Chapter 14 Abstract Classes and Interfaces 1 What is abstract class? Abstract class is just like other class, but it marks with abstract keyword. In abstract class, methods that we want to be overridden
More informationCSE 373 Spring 2010: Midterm #1 (closed book, closed notes, NO calculators allowed)
Name: Email address: CSE 373 Spring 2010: Midterm #1 (closed book, closed notes, NO calculators allowed) Instructions: Read the directions for each question carefully before answering. We may give partial
More informationITI Introduction to Computing II
ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 21, 2013 Abstract
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 24 October 29, 2018 Arrays, Java ASM Chapter 21 and 22 Announcements HW6: Java Programming (Pennstagram) Due TOMORROW at 11:59pm Reminder: please complete
More informationFinal Exam May 21, 2003
1.00 Introduction to Computers and Engineering Problem Solving Final Exam May 21, 2003 Name: Email Address: TA: Section: You have three hours to complete this exam. For coding questions, you do not need
More informationFinal Exam. COMP Summer I June 26, points
Final Exam COMP 14-090 Summer I 2000 June 26, 2000 200 points 1. Closed book and closed notes. No outside material allowed. 2. Write all answers on the test itself. Do not write any answers in a blue book
More informationJava: Classes. An instance of a class is an object based on the class. Creation of an instance from a class is called instantiation.
Java: Classes Introduction A class defines the abstract characteristics of a thing (object), including its attributes and what it can do. Every Java program is composed of at least one class. From a programming
More informationJava and OOP. Part 3 Extending classes. OOP in Java : W. Milner 2005 : Slide 1
Java and OOP Part 3 Extending classes OOP in Java : W. Milner 2005 : Slide 1 Inheritance Suppose we want a version of an existing class, which is slightly different from it. We want to avoid starting again
More informationLecture Notes Chapter #9_b Inheritance & Polymorphism
Lecture Notes Chapter #9_b Inheritance & Polymorphism Inheritance results from deriving new classes from existing classes Root Class all java classes are derived from the java.lang.object class GeometricObject1
More informationCS Introduction to Programming Midterm Exam #1 - Prof. Reed Spring What is your name?: (4 points for writing it on your answer sheet)
CS 102 - Introduction to Programming Midterm Exam #1 - Prof. Reed Spring 2008 What is your name?: (4 points for writing it on your answer sheet) There are two sections: I. True/False.....................
More informationCST242 Object-Oriented Programming Page 1
CST4 Object-Oriented Programming Page 4 5 6 67 67 7 8 89 89 9 0 0 0 Objected-Oriented Programming: Objected-Oriented CST4 Programming: CST4 ) Programmers should create systems that ) are easily extensible
More informationInheritance Motivation
Inheritance Inheritance Motivation Inheritance in Java is achieved through extending classes Inheritance enables: Code re-use Grouping similar code Flexibility to customize Inheritance Concepts Many real-life
More informationName CIS 201 Midterm II: Chapters 1-8
Name CIS 201 Midterm II: Chapters 1-8 December 15, 2010 Directions: This is a closed book, closed notes midterm. Place your answers in the space provided. The point value for each question is indicated.
More information1B1b Inheritance. Inheritance. Agenda. Subclass and Superclass. Superclass. Generalisation & Specialisation. Shapes and Squares. 1B1b Lecture Slides
1B1b Inheritance Agenda Introduction to inheritance. How Java supports inheritance. Inheritance is a key feature of object-oriented oriented programming. 1 2 Inheritance Models the kind-of or specialisation-of
More informationCS 101 Exam 1 Spring 200 Id Name
This exam is open text book and closed notes. Different questions have different points associated with them with later occurring questions having more worth than the beginning questions. Because your
More informationJava exercises January François de Coligny, Nicolas Beudez
Java exercises January 2018 - François de Coligny, Nicolas Beudez 0. Preliminary Create a directory called java/ on your machine to host all exercises. 1. Create a Training application package training;
More informationCS 113 MIDTERM EXAM 2 SPRING 2013
CS 113 MIDTERM EXAM 2 SPRING 2013 There are 18 questions on this test. The value of each question is: 1-15 multiple choice (3 pts) 17 coding problem (15 pts) 16, 18 coding problems (20 pts) You may get
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 26 March 23, 2016 Inheritance and Dynamic Dispatch Chapter 24 Inheritance Example public class { private int x; public () { x = 0; } public void incby(int
More informationKING FAHD UNIVERSITY OF PETROLEUM & MINERALS Information and Computer Science Department
KING FAHD UNIVERSITY OF PETROLEUM & MINERALS Information and Computer Science Department ICS-201 Introduction to Computer Science Lab 03: Java Virtual Machines and Java Packages Objectives: In this lab,
More informationMore About Classes CS 1025 Computer Science Fundamentals I Stephen M. Watt University of Western Ontario
More About Classes CS 1025 Computer Science Fundamentals I Stephen M. Watt University of Western Ontario The Story So Far... Classes as collections of fields and methods. Methods can access fields, and
More informationMore Java Basics. class Vector { Object[] myarray;... //insert x in the array void insert(object x) {...} Then we can use Vector to hold any objects.
More Java Basics 1. INHERITANCE AND DYNAMIC TYPE-CASTING Java performs automatic type conversion from a sub-type to a super-type. That is, if a method requires a parameter of type A, we can call the method
More informationCIS 120 Midterm II March 31, 2017 SOLUTIONS
CIS 120 Midterm II March 31, 2017 SOLUTIONS 1 1. OCaml and Java (14 points) Check one box for each part. a. The following OCaml function will terminate by exhausting stack space if called as loop 10: let
More informationCS 455 Midterm Exam 1 Spring 2015 [Bono] Thursday, Feb. 19, 2015
Name: USC username (e.g., ttrojan): CS 455 Midterm Exam 1 Spring 2015 [Bono] Thursday, Feb. 19, 2015 There are 5 problems on the exam, with 50 points total available. There are 7 pages to the exam, including
More informationPage 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
Page 1 of 16 HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2005 FINAL EXAMINATION 9am to 12noon, 19 DECEMBER 2005 Instructor: Alan McLeod If
More informationInheritance Systems. Merchandise. Television Camcorder Shirt Shoe Dress 9.1.1
Merchandise Inheritance Systems Electronics Clothing Television Camcorder Shirt Shoe Dress Digital Analog 9.1.1 Another AcademicDisciplines Hierarchy Mathematics Engineering Algebra Probability Geometry
More informationPolymorphism: Interfaces and Iteration. Fundamentals of Computer Science
Polymorphism: Interfaces and Iteration Fundamentals of Computer Science Outline A shape object hierarchy Classes that extend Versus classes that implements Java interfaces How Java handles multiple-inheritance
More informationObject Oriented Programming. Week 1 Part 3 Writing Java with Eclipse and JUnit
Object Oriented Programming Part 3 Writing Java with Eclipse and JUnit Today's Lecture Test Driven Development Review (TDD) Building up a class using TDD Adding a Class using Test Driven Development in
More informationCSCI 136 Programming Exam #2 Fundamentals of Computer Science II Spring 2012
CSCI 136 Programming Exam #2 Fundamentals of Computer Science II Spring 2012 This part of the exam is like a mini- programming assignment. You will create a program, compile it, and debug it as necessary.
More informationDesign Pattern - Factory Pattern
Design Pattern - Factory Pattern Factory pattern is one of most used design pattern in Java. This type of design pattern comes under creational pattern as this pattern provides one of the best ways to
More informationBuilding Java Programs
Building Java Programs Chapter 8 Lecture 8-3: Encapsulation; Homework 8 (Critters) reading: 8.3-8.4 Encapsulation reading: 8.4 2 Encapsulation encapsulation: Hiding implementation details from clients.
More informationFaculty of Science COMP-202B - Introduction to Computing I (Winter 2009) Midterm Examination
First Name: Last Name: McGill ID: Section: Faculty of Science COMP-202B - Introduction to Computing I (Winter 2009) Midterm Examination Monday, March 9, 2009 Examiners: Mathieu Petitpas [Section 1] 18:30
More informationCSE 373 Autumn 2010: Midterm #1 (closed book, closed notes, NO calculators allowed)
Name: Email address: CSE 373 Autumn 2010: Midterm #1 (closed book, closed notes, NO calculators allowed) Instructions: Read the directions for each question carefully before answering. We may give partial
More informationInheritance (Deitel chapter 9)
Inheritance (Deitel chapter 9) 1 2 Plan Introduction Superclasses and Subclasses protected Members Constructors and Finalizers in Subclasses Software Engineering with Inheritance 3 Introduction Inheritance
More informationCMPT-166: Sample Final Exam Answer Key
CMPT 166, Summer 2012, Surrey Sample Final Exam Answer Key Page 1 of 9 CMPT-166: Sample Final Exam Answer Key Last name exactly as it appears on your student card First name exactly as it appears on your
More informationIntroduction to Java Applications
2 Introduction to Java Applications OBJECTIVES In this chapter you will learn: To write simple Java applications. To use input and output statements. Java s primitive types. Basic memory concepts. To use
More informationComposite Pattern - Shapes Example - Java Sourcecode
Composite Pattern - Shapes Example - Java Sourcecode In graphics editors a shape can be basic or complex. An example of a simple shape is a line, where a complex shape is a rectangle which is made of four
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 22 March 14, 2018 Static Methods, Java Arrays Chapters 20 & 21 Announcements HW6: Java Programming (Pennstagram) Due: Tuesday the 20 th at 11:59pm
More informationMore on inheritance CSCI 136: Fundamentals of Computer Science II Keith Vertanen Copyright 2014
More on inheritance CSCI 136: Fundamentals of Computer Science II Keith Vertanen Copyright 2014 Object hierarchies Overview Several classes inheriting from same base class Concrete versus abstract classes
More informationCH. 2 OBJECT-ORIENTED PROGRAMMING
CH. 2 OBJECT-ORIENTED PROGRAMMING ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN JAVA, GOODRICH, TAMASSIA AND GOLDWASSER (WILEY 2016) OBJECT-ORIENTED
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 25 November 1, 2017 Inheritance and Dynamic Dispatch (Chapter 24) Announcements HW7: Chat Client Available Soon Due: Tuesday, November 14 th at 11:59pm
More informationProblem Grade Total
CS 101, Prof. Loftin: Final Exam, May 11, 2009 Name: All your work should be done on the pages provided. Scratch paper is available, but you should present everything which is to be graded on the pages
More informationQUIZ 2 Introduction to Computer Science (COMP 250) Mon. March 2, 2009 Professor Michael Langer
QUIZ 2 Introduction to Computer Science (COMP 250) Mon. March 2, 2009 Professor Michael Langer STUDENT NAME: ID: The exam consists of five questions. There are a total of 10 points. You may use the back
More informationPolymorphism: Inheritance Interfaces
Polymorphism: Inheritance Interfaces 256 Recap Finish Deck class methods Questions about assignments? Review Player class for HW9 (starter zip posted) Lessons Learned: Arrays of objects require multiple
More informationCOMP200 INHERITANCE. OOP using Java, from slides by Shayan Javed
1 1 COMP200 INHERITANCE OOP using Java, from slides by Shayan Javed 2 Inheritance Derive new classes (subclass) from existing ones (superclass). Only the Object class (java.lang) has no superclass Every
More informationComputing Science 114 Solutions to Midterm Examination Tuesday October 19, In Questions 1 20, Circle EXACTLY ONE choice as the best answer
Computing Science 114 Solutions to Midterm Examination Tuesday October 19, 2004 INSTRUCTOR: I E LEONARD TIME: 50 MINUTES In Questions 1 20, Circle EXACTLY ONE choice as the best answer 1 [2 pts] What company
More informationThis exam is open book. Each question is worth 3 points.
This exam is open book. Each question is worth 3 points. Page 1 / 15 Page 2 / 15 Page 3 / 12 Page 4 / 18 Page 5 / 15 Page 6 / 9 Page 7 / 12 Page 8 / 6 Total / 100 (maximum is 102) 1. Are you in CS101 or
More informationPage 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
Page 1 of 16 SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2004 FINAL EXAMINATION 9am to 12noon, 22 DECEMBER 2004 Instructors: Alan
More informationInheritance & Polymorphism Recap. Inheritance & Polymorphism 1
Inheritance & Polymorphism Recap Inheritance & Polymorphism 1 Introduction! Besides composition, another form of reuse is inheritance.! With inheritance, an object can inherit behavior from another object,
More informationAP Computer Science Chapter 10 Implementing and Using Classes Study Guide
AP Computer Science Chapter 10 Implementing and Using Classes Study Guide 1. A class that uses a given class X is called a client of X. 2. Private features of a class can be directly accessed only within
More informationCSE 331 Final Exam 6/7/16
Name There are 12 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes, closed
More informationJava Classes & Primitive Types
Java Classes & Primitive Types Rui Moreira Classes Ponto (from figgeom) x : int = 0 y : int = 0 n Attributes q Characteristics/properties of classes q Primitive types (e.g., char, byte, int, float, etc.)
More information1.00 Lecture 13. Inheritance
1.00 Lecture 13 Inheritance Reading for next time: Big Java: sections 10.5-10.6 Inheritance Inheritance allows you to write new classes based on existing (super or base) classes Inherit super class methods
More informationJava Classes & Primitive Types
Java Classes & Primitive Types Rui Moreira Classes Ponto (from figgeom) x : int = 0 y : int = 0 n Attributes q Characteristics/properties of classes q Primitive types (e.g., char, byte, int, float, etc.)
More informationObject- Oriented Analysis, Design and Programming. Instructions. Medialogy, 4 th Semester, Aalborg. Tuesday 30 August 2011,
Object- Oriented Analysis, Design and Programming Medialogy, 4 th Semester, Aalborg Tuesday 30 August 2011, 10.00-13.00 Instructions You have 3 hours to complete this examination. Neither written material
More informationSCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 2 EXAMINATIONS 2013/2014 CI101/CI101H. Programming
s SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 2 EXAMINATIONS 2013/2014 CI101/CI101H Programming Time allowed: THREE hours Answer: ALL questions Items permitted: Items supplied: There is no
More informationChapter 21- Using Generics Case Study: Geometric Bunch. Class: Driver. package csu.matos; import java.util.arraylist; public class Driver {
Chapter 21- Using Generics Case Study: Geometric Bunch In this example a class called GeometricBunch is made to wrap around a list of GeometricObjects. Circle and Rectangle are subclasses of GeometricObject.
More informationITI Introduction to Computing II
ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Interface Abstract data types Version of January 26, 2013 Abstract These lecture notes are meant
More informationCS 455 Midterm Exam 1 Fall 2017 [Bono] Thursday, Sep. 28, 2017
Name: USC NetID (e.g., ttrojan): CS 455 Midterm Exam 1 Fall 2017 [Bono] Thursday, Sep. 28, 2017 There are 6 problems on the exam, with 55 points total available. There are 10 pages to the exam (5 pages
More informationIST311. Advanced Issues in OOP: Inheritance and Polymorphism
IST311 Advanced Issues in OOP: Inheritance and Polymorphism IST311/602 Cleveland State University Prof. Victor Matos Adapted from: Introduction to Java Programming: Comprehensive Version, Eighth Edition
More informationJAVA V Assertions Java, winter semester
JAVA Assertions 1 Assertion since Java 1.4 the statement with a boolean expression a developer supposes that the expression is always satisfied (evaluates to true) if it is evaluated to false -> error
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 21 March 12, 2018 Java: Objects, Interfaces, Static Members Chapters 19 & 20 Announcements Java Bootcamp Tonight!! Towne 100, 6-8 pm HW06: Pennstagram
More informationFinal Exam. Kenneth J. Goldman December 18, Name: Student ID Number: Signature:
Washington University CSE131. Computer Science I Final Exam Kenneth J. Goldman December 18, 2007 Name: Student ID Number: Signature: Directions: This exam is closed book and closed notes. No electronic
More information