Department of Civil and Environmental Engineering, Spring Semester, ENCE 688R: Midterm Exam: 1 1/2 Hours, Open Book and Open Notes

Size: px
Start display at page:

Download "Department of Civil and Environmental Engineering, Spring Semester, ENCE 688R: Midterm Exam: 1 1/2 Hours, Open Book and Open Notes"

Transcription

1 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 Total 100 1

2 Question 1: 30 points This question covers basic Java programming. Figure 1 shows a 10cm by 5cm sheet of metal that will be folded into a small open box. 5 cm x cm 10 cm Figure 1: Open box folded from a rectangular sheet of metal. The following program computes and prints the surface area and volume as a function of the box height x. /* * ================================================================== * FoldedBox.java: Compute the surface area and volume of an * open box cut from a metal sheet 5 cm by 10 cm. * * Written By: Mark Austin March 2016 * ================================================================== */ import java.lang.math; public class FoldedBox { public static void main( String args[] ) { float farea; float fvolume; float MinVolume = 0.0f; float MaxVolume = 0.0f; float MinArea = 0.0f; float MaxArea = 0.0f; // Print header and setup table... System.out.println("Surface Area and Volume of Folded Open Box"); System.out.println(" "); System.out.println(""); System.out.println(" X Area Volume"); System.out.println(" "); 2

3 // Loop over side lengths... for ( float fx = 0.0f; fx <= 2.5; fx = fx f ) { // Compute area and volume farea = surfacearea(fx); fvolume = boxvolume(fx); // Check for new min and maximum. if(fx == 0.0) { MinArea = MaxArea = farea; MinVolume = MaxVolume = fvolume; else { MinArea = Math.min ( MinArea, farea ); MaxArea = Math.max ( MaxArea, farea ); MinVolume = Math.min ( MinVolume, fvolume ); MaxVolume = Math.max ( MaxVolume, fvolume ); // Format and print results. System.out.printf(" %4.2f %9.2f %11.2f\n", fx, farea, fvolume); // Print max and min values. System.out.println(" "); System.out.println(""); System.out.println("Minimum Surface Area = " + MinArea ); System.out.println("Maximum Surface Area = " + MaxArea ); System.out.println("Minimum Volume = " + MinVolume ); System.out.println("Maximum Volume = " + MaxVolume ); /* * =============================================== * Method surfacearea() : compute box surface area * * Input : fx * Output : float farea * =============================================== */ static float surfacearea( float fx ) { return (float) (5.0* *fx*fx); /* * =============================================== * Method boxvolume() : compute box volume * * Input : fx * Output : float fvolume 3

4 * =============================================== */ static float boxvolume(float fx) { return (float) ((5.0-2*fx)*(10.0-2*fx)*fx); The formatted output is as follows: prompt >> prompt >> java FoldedBox Surface Area and Volume of Folded Open Box X Area Volume Minimum Surface Area = 25.0 Maximum Surface Area = 50.0 Minimum Volume = 0.0 Maximum Volume = 24.0 prompt >> exit Please look at the source code carefully, and then answer the following questions: [1a] (3 pts). What are the two types of comment statement used in the FoldedBox program? 4

5 [1b] (3 pts). What does the line of code import java.lang.math; do? And why is it included in this program? [1c] (3 pts). Suppose that the statement of code float MinVolume = 0.0f; is changed to float MinVolume = 0.0; and then the program is compiled. What will the Java compiler complain about? [1d] (3 pts). List the methods whose source code is contained within FoldedBox. 5

6 [1e] (4 pts). The program execution will begin in the method main.. What are the purposes of each keyword in the line: public static void main ( String [] args ) {... [1f] (6 pts). Construct a table showing the values of fvolume, MinVolume, and MaxVolume as the for loop increments from fx = 0.0f to 2.5 in increments of

7 [1g] (3 pts). Briefly explain the purpose of the terms %4.2f, %9.2f and %11.2f in System.out.printf(" %4.2f %9.2f %11.2f\n", fx, farea, fvolume); [1h] (3 pts). What is the purpose of the keyword static in static float surfacearea( float fx ) {... [1i] (2 pts). What are the files that will exist before and after compilation? 7

8 Question 2: 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; this.dside2 = dside2; 8

9 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 ); System.out.println(" "); 9

10 Please look at the source code carefully and answer the questions that follow: [2a] (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. [2b] (3 pts). What command would you give to run the Rectangle program? (Please do not write: I d press the run button). [2c] (3 pts). What will the program output look like? 10

11 [2d] (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. [2e] (4 pts). What is the purpose of the method tostring() in the statement? System.out.println( ra.tostring() ); 11

12 Now let s move onto Shape.java. [2f] (5 pts). List two ways in which an abstract class (e.g., Shape.java) differs from a regular class (e.g., Circle.java). [2g] (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. 12

13 [2h] (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. [2i] (5 pts). Briefly indicated how you would modify the body of main() to take advantage of Java Generics. 13

14 Question 3: 30 points In this question we explore the modeling of many-to-many relationships between US states and their membership in geographical regions. Geographical Regions US States West Coast East Coast WA CA CO MD NY TX FL Southern States Figure 3: Schematic for US states and their membership in geographical regions. As a starting point, the right-hand side of Figure 3 shows a sampling of US states CA is an abbreviation for California, MD stands for Maryland, FL stands for Florida, and so forth. The left-hand side of Figure 3 shows how groups of states can be bundled into geographical regions. For example, CA and WA belong to the West Coast region; Maryland and Florida are part of the East Coast region; Texas and Florida belong to the Southern States region. A many-to-many relationship exists between geographical regions and US states because regions contain multiple states and, conversely, states such as Florida belong to multiple regions. Now let s assume that software for modeling the many-to-many relationship is contained into files, State.java and GeographicalRegion.java. A third file, SimUSA.java, creates state and geographical region objects, and then systematically assembles dependencies in the many-to-many relationship. File: State.java source code /* * ======================================================= * State.java; Create a "US state" object... * ======================================================= */ package geography; import java.util.collection; 14

15 import java.util.arraylist; import java.util.iterator; public class State { private String sname; private int ipopulation; // Collection of regions to which the state belongs. private Collection<GeographicalRegion> regions; // Constuctor method... public State( String sname ) { this.sname = sname; regions = new ArrayList<GeographicalRegion>(); // Set and get methods for the State name... public void setname( String sname ) { this.sname = sname; public String getname() { return sname; // Set and get methods for the State Population... public void setpopulation( int ipopulation ) { this.ipopulation = ipopulation; public int getpopulation() { return ipopulation; // Add a State to a Region... public void addgeographicalregion( GeographicalRegion region ) { // Add new region to states membership... if ( getgeographicalregions().contains(region) == false ) { getgeographicalregions().add(region); // Update list of states belonging to region... if ( region.getstates().contains(this) == false ) { region.getstates().add(this); 15

16 // Return collection of regions... public Collection<GeographicalRegion> getgeographicalregions() { return regions; // Create String representation of student object... public String tostring() { String s = "State: " + sname + "\n"; s = s + "Population: " + ipopulation + "\n"; s = s + "Regions: "; if ( regions.size() == 0 ) s = s + " none \n"; else { Iterator iterator1 = regions.iterator(); while ( iterator1.hasnext()!= false ) { GeographicalRegion r = (GeographicalRegion) iterator1.next(); s = s + r.getname() + " "; s = s + "\n"; return s; File: GeographicalRegion.java source code /* * ====================================================================== * GeographicalRegion.java; Create simple model of a geographical region. * ====================================================================== */ package geography; import java.util.arraylist; import java.util.collection; import java.util.iterator; public class GeographicalRegion { private String sname; // Setup collection of states... private Collection<State> states; 16

17 // Constructor method... public GeographicalRegion(){ states = new ArrayList<State>(); // Methods to deal with the region name... public String getname() { return sname; public void setname(string regionname ) { this.sname = regionname; // Add a state to the geographical region... public void addstate( State st ) { if ( getstates().contains( st ) == false ) { getstates().add( st ); // Update regions on the state side... if ( st.getgeographicalregions().contains(this) == false ) { st.getgeographicalregions().add(this); public Collection<State> getstates() { return states; public void setstate( Collection<State> states ) { this.states = states; // Compute total population of the geographical region... public int getpopulation() { int ipopulation = 0;... Details of source code removed... See Question [3f]... return ipopulation; // Create a String representation for the geographical region... public String tostring() { String s = "Geographical Region: " + sname + "\n"; s = s + "States: "; if ( states.size() == 0 ) 17

18 s = s + " none \n"; else { Iterator iterator1 = states.iterator(); while ( iterator1.hasnext()!= false ) { State st = (State) iterator1.next(); s = s + st.getname() + " "; s = s + "\n"; s = s + "Population: " + getpopulation() + "\n"; return s; File: SimUSA.java source code /* * ======================================================================== * SimUSA.java: Simulate many-to-many relationships between US states * and the geographical regions to which they belong. * ======================================================================== */ package demo; import geography.*; public class SimUSA { public static void main( String[] args ) { // [a]: Create objects for US states... State md = new State( "MD" ); md.setpopulation( 5 ); State fl = new State( "FL" ); fl.setpopulation( 10 ); State ca = new State( "CA" ); ca.setpopulation( 40 ); State tx = new State( "TX" ); tx.setpopulation( 30 ); // [b]: Add states to the East Coast Region... GeographicalRegion east = new GeographicalRegion(); east.setname("east Coast"); east.addstate( md ); east.addstate( fl ); 18

19 // [c]: Add states to the Southern Region... GeographicalRegion south = new GeographicalRegion(); south.setname("southern States"); south.addstate( tx ); south.addstate( fl ); // [d]: Print details of state-region assocations... System.out.println( "Part 1: Summary of State/Geographical Region Associations" ); System.out.println( "=========================================================" ); System.out.println( md ); System.out.println( fl ); // [e]: Print details of region-state assocations... System.out.println( "Part 2: Summary of Geographical Region/State Associations" ); System.out.println( "=========================================================" ); System.out.println( east ); System.out.println( south ); The script of program input and output is as follows: prompt >> ant run02 Buildfile: /Users/austin/ence688r.d/exam-code.d/build.xml compile: [javac] /Users/austin/ence688r.d/exam-code.d/build.xml:9: run02: [java] Part 1: Summary of State/Geographical Region Associations [java] ========================================================= [java] State: MD [java] Population: 5 [java] Regions: East Coast [java] [java] State: FL [java] Population: 10 [java] Regions: East Coast Southern States [java] [java] Part 2: Summary of Geographical Region/State Associations [java] ========================================================= [java] Geographical Region: East Coast [java] States: MD FL [java] Population: 15 [java] 19

20 [java] Geographical Region: Southern States [java] States: TX FL [java] Population: 40 [java] BUILD SUCCESSFUL Total time: 1 second prompt >> exit Please look at the source code carefully and answer the questions that follow: [3a] (5 pts). Draw and label a diagram that shows the organizational arrangement of java packages and user-defined java source code files. 20

21 [3b] (5 pts). Draw and label a diagram that shows the relationship among the State, GeographicalRegion and SimUSA classes. [3c] (5 pts). Draw and label a diagram showing the layout of memory generated by sections [a] through [c] of SimUSA.java. 21

22 [3d] (5 pts). What is the purpose of the syntax <GeographicalRegion> in the statement: private Collection<GeographicalRegion> regions; [3e] (5 pts). Briefly explain the way in which the classes State and GeographicalRegion would change if the many-to-many relationships were implemented as HashSets instead of ArrayLists. 22

23 [3f] (5 pts). Write the code missing from the method getpopulation() in GeographicalRegion.java, i.e, public int getpopulation() { int ipopulation = 0;... fill in the missing details here... return ipopulation; 23

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, ENCE 688R: Midterm Exam: 1 1/2 Hours, Open Book and Open Notes 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 1 30 2 30 3 40 Total 100 1 Question

More information

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, 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 information

Department 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, 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 information

Department 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, 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 information

Problem 8.1: Model rectangles with Vertices...

Problem 8.1: Model rectangles with Vertices... ------------------------------------------------------------------------- ENCE 688R: Solutions to Homework 2 March 2016 ------------------------------------------------------------------------- -------------------------------------------------------------------------

More information

Engineering Software Development in Java

Engineering 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 information

The source code is as follows:

The source code is as follows: ENCE 688R: Solutions to Homework 1 March 2017 ========================================================================= Problem 7.2: Compute and print sum of numbers below 1000 that are either multiples

More information

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

First 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 information

7.1 It is well known that the formula for converting a temperature in Celsius to Fahrenheit is. o F = 9 5 o C (7.10)

7.1 It is well known that the formula for converting a temperature in Celsius to Fahrenheit is. o F = 9 5 o C (7.10) 190 Engineering Software Development in Java 7.15 Exercises The problems in this section cover the basics, including use of keyboard input, looping and branching constructs, simple arrays, and generation

More information

Practice Midterm 1. Problem Points Score TOTAL 50

Practice 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 information

Final Exam May 21, 2003

Final 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 information

CSE 373 Spring 2010: Midterm #1 (closed book, closed notes, NO calculators allowed)

CSE 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 information

AP Computer Science Chapter 10 Implementing and Using Classes Study Guide

AP 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 information

The Nervous Shapes Example

The 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 information

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

F 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 information

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

First 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 information

Problem 7.4: Racetrack

Problem 7.4: Racetrack ENCE 688R: Solutions to Homework 1 March 2016 Problem 7.3: Find smallest number that is evenly divisible by all of the numbers 1 through 20. Source code: / =====================================================================

More information

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

1. 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 information

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

Abstract 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 information

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)

CSE 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 information

SPRING 13 CS 0007 FINAL EXAM V2 (Roberts) Your Name: A pt each. B pt each. C pt each. D or 2 pts each

SPRING 13 CS 0007 FINAL EXAM V2 (Roberts) Your Name: A pt each. B pt each. C pt each. D or 2 pts each Your Name: Your Pitt (mail NOT peoplesoft) ID: Part Question/s Points available Rubric Your Score A 1-6 6 1 pt each B 7-12 6 1 pt each C 13-16 4 1 pt each D 17-19 5 1 or 2 pts each E 20-23 5 1 or 2 pts

More information

QUIZ 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 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 information

CSE 401 Final Exam. December 16, 2010

CSE 401 Final Exam. December 16, 2010 CSE 401 Final Exam December 16, 2010 Name You may have one sheet of handwritten notes plus the handwritten notes from the midterm. You may also use information about MiniJava, the compiler, and so forth

More information

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

University 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 information

CSE 8B Programming Assignments Spring Programming: You will have 5 files all should be located in a dir. named PA3:

CSE 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 information

CSE 373 Autumn 2010: Midterm #1 (closed book, closed notes, NO calculators allowed)

CSE 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 information

ENCE 688R Civil Information Systems. The Java Language. Mark Austin.

ENCE 688R Civil Information Systems. The Java Language. Mark Austin. p. 1/4 ENCE 688R Civil Information Systems The Java Language Mark Austin E-mail: austin@isr.umd.edu Department of Civil and Environmental Engineering, University of Maryland, College Park p. 2/4 Lecture

More information

CS Introduction to Programming Midterm Exam #1 - Prof. Reed Spring What is your name?: (4 points for writing it on your answer sheet)

CS 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 information

Supplementary Test 1

Supplementary Test 1 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 Supplementary Test 1 Question

More information

1. ArrayList and Iterator in Java

1. ArrayList and Iterator in Java 1. ArrayList and Iterator in Java Inserting elements between existing elements of an ArrayList or Vector is an inefficient operation- all element after the new one must be moved out of the way which could

More information

PROGRAMMING FUNDAMENTALS

PROGRAMMING FUNDAMENTALS PROGRAMMING FUNDAMENTALS Q1. Name any two Object Oriented Programming languages? Q2. Why is java called a platform independent language? Q3. Elaborate the java Compilation process. Q4. Why do we write

More information

YOU ARE ALLOWED TO HAVE ONLY THE FOLLOWING ON YOUR DESK OR WORKTABLE:

YOU ARE ALLOWED TO HAVE ONLY THE FOLLOWING ON YOUR DESK OR WORKTABLE: PRINT YOUR NAME: KEY I have not looked at anyone else s paper, and I have not obtained unauthorized help in completing this exam. Also, I have adhered to and upheld all standards of honesty as stated in

More information

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

CS 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 information

ESC101 : Fundamental of Computing

ESC101 : Fundamental of Computing ESC101 : Fundamental of Computing End Semester Exam 19 November 2008 Name : Roll No. : Section : Note : Read the instructions carefully 1. You will lose 3 marks if you forget to write your name, roll number,

More information

Chapter 9 - Object-Oriented Programming: Polymorphism

Chapter 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 information

Give one example where you might wish to use a three dimensional array

Give one example where you might wish to use a three dimensional array CS 110: INTRODUCTION TO COMPUTER SCIENCE SAMPLE TEST 3 TIME ALLOWED: 60 MINUTES Student s Name: MAXIMUM MARK 100 NOTE: Unless otherwise stated, the questions are with reference to the Java Programming

More information

CMSC 433 Section 0101 Fall 2012 Midterm Exam #1

CMSC 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 information

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

This 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 information

IUE Faculty of Engineering and Computer Sciences Spring Semester

IUE Faculty of Engineering and Computer Sciences Spring Semester IUE Faculty of Engineering and Computer Sciences 2010-2011 Spring Semester CS116 Introduction to Programming II Midterm Exam II (May 11 th, 2011) This exam document has 5 pages and 4 questions. The exam

More information

CSE 332 Spring 2014: Midterm Exam (closed book, closed notes, no calculators)

CSE 332 Spring 2014: Midterm Exam (closed book, closed notes, no calculators) Name: Email address: Quiz Section: CSE 332 Spring 2014: Midterm Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We will

More information

CSE 373 Winter 2009: Midterm #1 (closed book, closed notes, NO calculators allowed)

CSE 373 Winter 2009: Midterm #1 (closed book, closed notes, NO calculators allowed) Name: Email address: CSE 373 Winter 2009: Midterm #1 (closed book, closed notes, NO calculators allowed) Instructions: Read the directions for each question carefully before answering. We may give partial

More information

University of Massachusetts Amherst, Electrical and Computer Engineering

University of Massachusetts Amherst, Electrical and Computer Engineering University of Massachusetts Amherst, Electrical and Computer Engineering ECE 122 Midterm Exam 1 Makeup Answer key March 2, 2018 Instructions: Closed book, Calculators allowed; Duration:120 minutes; Write

More information

CS-140 Fall 2017 Test 1 Version Practice Practice for Nov. 20, Name:

CS-140 Fall 2017 Test 1 Version Practice Practice for Nov. 20, Name: CS-140 Fall 2017 Test 1 Version Practice Practice for Nov. 20, 2017 Name: 1. (10 points) For the following, Check T if the statement is true, the F if the statement is false. (a) T F : If a child overrides

More information

Instance Method Development Demo

Instance Method Development Demo Instance Method Development Demo Write a class Person with a constructor that accepts a name and an age as its argument. These values should be stored in the private attributes name and age. Then, write

More information

Computer Science 145

Computer Science 145 Name: Computer Science 145 Final Exam Answer Sheet Fall 2016 1. a b c d 8. 2. a b c d 9. a b c d 3. a b c d e 10. a b c d 4. a b c d 11. 5. a b c d 12. 6. 13. 7. 14. a b c d 15. 16. 17. 1 18. 19. 2 20.

More information

a) Answer all questions. b) Write your answers in the space provided. c) Show all calculations where applicable.

a) Answer all questions. b) Write your answers in the space provided. c) Show all calculations where applicable. Name: Please fill in your Student Number and Name. Student Number : Student Number: University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ 2008 January Exam Question Max Internal

More information

CS 101 Exam 1 Spring 200 Id Name

CS 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 information

SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 2 EXAMINATIONS 2013/2014 CI101/CI101H. Programming

SCHOOL 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 information

SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 1 EXAMINATIONS 2015/2016 CI101 / CI177. Programming

SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 1 EXAMINATIONS 2015/2016 CI101 / CI177. Programming s SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 1 EXAMINATIONS 2015/2016 CI101 / CI177 Programming Time allowed: THREE hours: Answer: ALL questions Items permitted: Items supplied: There is

More information

Midterm I - CSE11 Fall 2013 CLOSED BOOK, CLOSED NOTES 50 minutes, 100 points Total.

Midterm I - CSE11 Fall 2013 CLOSED BOOK, CLOSED NOTES 50 minutes, 100 points Total. Midterm I - CSE11 Fall 2013 CLOSED BOOK, CLOSED NOTES 50 minutes, 100 points Total. Name: ID: Problem 1) (8 points) For the following code segment, what are the values of i, j, k, and d, after the segment

More information

Working with Objects and Classes

Working 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 information

Midterm Examination (MTA)

Midterm 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 information

Simple Java Reference

Simple Java Reference Simple Java Reference This document provides a reference to all the Java syntax used in the Computational Methods course. 1 Compiling and running... 2 2 The main() method... 3 3 Primitive variable types...

More information

CIS 120 Midterm II March 31, 2017 SOLUTIONS

CIS 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 information

Computing 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, 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 information

Sample Examination Paper Programming and Software Development

Sample Examination Paper Programming and Software Development 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

More information

Object-Oriented Programming and Software Engineering CITS1001 MID-SEMESTER TEST

Object-Oriented Programming and Software Engineering CITS1001 MID-SEMESTER TEST Object-Oriented Programming and Software Engineering School of Computer Science & Software Engineering The University of Western Australia CITS1001 MID-SEMESTER TEST Semester 1, 2013 CITS1001 This Paper

More information

Exam Duration: 2hrs and 30min Software Design

Exam Duration: 2hrs and 30min Software Design Exam Duration: 2hrs and 30min. 433-254 Software Design Section A Multiple Choice (This sample paper has less questions than the exam paper The exam paper will have 25 Multiple Choice questions.) 1. Which

More information

CSE 142 Sp02 Final Exam Version A Page 1 of 14

CSE 142 Sp02 Final Exam Version A Page 1 of 14 CSE 142 Sp02 Final Exam Version A Page 1 of 14 Basic reference information about collection classes that you may find useful when answering some of the questions. Methods common to all collection classes

More information

CS 1316 Exam 1 Summer 2009

CS 1316 Exam 1 Summer 2009 1 / 8 Your Name: I commit to uphold the ideals of honor and integrity by refusing to betray the trust bestowed upon me as a member of the Georgia Tech community. CS 1316 Exam 1 Summer 2009 Section/Problem

More information

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible) Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program

More information

CS 455 Midterm Exam 1 Fall 2017 [Bono] Thursday, Sep. 28, 2017

CS 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 information

CMPT-166: Sample Midterm

CMPT-166: Sample Midterm CMPT 166, Fall 2016, Surrey Sample Midterm 1 Page 1 of 11 CMPT-166: Sample Midterm Last name exactly as it appears on your student card First name exactly as it appears on your student card Student Number

More information

APCS Semester #1 Final Exam Practice Problems

APCS Semester #1 Final Exam Practice Problems Name: Date: Per: AP Computer Science, Mr. Ferraro APCS Semester #1 Final Exam Practice Problems The problems here are to get you thinking about topics we ve visited thus far in preparation for the semester

More information

MACS 261J Final Exam. Question: Total Points: Score:

MACS 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 information

MID-SEMESTER TEST 2014

MID-SEMESTER TEST 2014 MID-SEMESTER TEST 2014 CITS1001 Object-Oriented Programming and Software Engineering School of Computer Science and Software Engineering The University of Western Australia First Name Family Name Student

More information

Use the scantron sheet to enter the answer to questions (pages 1-6)

Use the scantron sheet to enter the answer to questions (pages 1-6) Use the scantron sheet to enter the answer to questions 1-100 (pages 1-6) Part I. Mark A for True, B for false. (1 point each) 1. Abstraction allow us to specify an object regardless of how the object

More information

Control Structures (Deitel chapter 4,5)

Control Structures (Deitel chapter 4,5) Control Structures (Deitel chapter 4,5) 1 2 Plan Control Structures ifsingle-selection Statement if else Selection Statement while Repetition Statement for Repetition Statement do while Repetition Statement

More information

CS170 Introduction to Computer Science Midterm 2

CS170 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 information

Problem Grade Total

Problem 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 information

CS 113 MIDTERM EXAM 2 SPRING 2013

CS 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 information

Last Name: Circle One: OCW Non-OCW

Last Name: Circle One: OCW Non-OCW First Name: AITI 2004: Exam 1 June 30, 2004 Last Name: Circle One: OCW Non-OCW Read Instructions Carefully! This is a 3 hour closed book exam. No calculators are allowed. Please write clearly if we cannot

More information

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

Q1 Q2 Q3 Q4 Q5 Total 1 * 7 1 * 5 20 * * Final marks Marks First Question Page 1 of 6 Template no.: A Course Name: Computer Programming1 Course ID: Exam Duration: 2 Hours Exam Time: Exam Date: Final Exam 1'st Semester Student no. in the list: Exam pages: Student's Name: Student

More information

Inheritance & Polymorphism Recap. Inheritance & Polymorphism 1

Inheritance & 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 information

CS 1331 Exam 1 ANSWER KEY

CS 1331 Exam 1 ANSWER KEY CS 1331 Exam 1 Fall 2016 ANSWER KEY Failure to properly fill in the information on this page will result in a deduction of up to 5 points from your exam score. Signing signifies you are aware of and in

More information

CS100M November 30, 2000

CS100M November 30, 2000 CS00M November 30, 2000 Makeup Solutions 7:30 PM 9:30 PM (Print last name, first name, middle initial/name) (Student ID) Statement of integrity: I did not, and will not, break the rules of academic integrity

More information

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

I pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class. Name: Covers Chapters 1-3 50 mins CSCI 1301 Introduction to Programming Armstrong Atlantic State University Instructor: Dr. Y. Daniel Liang I pledge by honor that I will not discuss this exam with anyone

More information

CS 307 Midterm 1 Fall 2007

CS 307 Midterm 1 Fall 2007 Points off 1 2 3 4 Total off Net Score CS 307 Midterm 1 Fall 2007 Your Name Your UTEID Circle yours TA s name: David Joseph Ola Instructions: 1. Please turn off your cell phones 2. There are 4 questions

More information

CS-140 Fall 2018 Test 2 Version A Nov. 12, Name:

CS-140 Fall 2018 Test 2 Version A Nov. 12, Name: CS-140 Fall 2018 Test 2 Version A Nov. 12, 2018 Name: 1. (10 points) For the following, Check T if the statement is true, or F if the statement is false. (a) X T F : A class in Java contains fields, and

More information

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved. Assoc. Prof. Dr. Marenglen Biba Before writing a program to solve a problem, have a thorough understanding of the problem and a carefully planned approach to solving it. Understand the types of building

More information

Design Patterns - Decorator Pattern

Design 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 information

CMSC 132: Object-Oriented Programming II. Inheritance

CMSC 132: Object-Oriented Programming II. Inheritance CMSC 132: Object-Oriented Programming II Inheritance 1 Mustang vs Model T Ford Mustang Ford Model T 2 Interior: Mustang vs Model T 3 Frame: Mustang vs Model T Mustang Model T 4 Compaq: old and new Price:

More information

CS 101 Fall 2006 Midterm 3 Name: ID:

CS 101 Fall 2006 Midterm 3 Name:  ID: You only need to write your name and e-mail ID on the first page. This exam is CLOSED text book, closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts, so be sure

More information

CSE 1223: Exam II Autumn 2016

CSE 1223: Exam II Autumn 2016 CSE 1223: Exam II Autumn 2016 Name: Instructions: Do not open the exam before you are told to begin. This exam is closed book, closed notes. You may not use any calculators or any other kind of computing

More information

CS445 Week 9: Lecture

CS445 Week 9: Lecture CS445 Week 9: Lecture Objectives: To discuss the solution of the midterm and answer any doubts about grading issues. Also, during the discussion, refresh the topics from the first part of the course. Reading

More information

Midterm Exam 2 CS 455, Fall 2013

Midterm Exam 2 CS 455, Fall 2013 Name: USC loginid (e.g., ttrojan): Midterm Exam 2 CS 455, Fall 2013 Wednesday, November 6, 2013 There are 9 problems on the exam, with 58 points total available. There are 8 pages to the exam, including

More information

ITI Introduction to Computing II

ITI 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 information

CS111: PROGRAMMING LANGUAGE II

CS111: PROGRAMMING LANGUAGE II CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1(c): Java Basics (II) Lecture Contents Java basics (part II) Conditions Loops Methods Conditions & Branching Conditional Statements A

More information

STAAR Category 3 Grade 7 Mathematics TEKS 7.9D. Student Activity 1

STAAR Category 3 Grade 7 Mathematics TEKS 7.9D. Student Activity 1 Student Activity 1 Work with your partner to answer the following questions. Problem 1: A triangular prism has lateral faces and faces called bases. The bases are in the shape of a. The lateral faces are

More information

Question Points Score

Question Points Score CS 453 Introduction to Compilers Midterm Examination Spring 2009 March 12, 2009 75 minutes (maximum) Closed Book You may use one side of one sheet (8.5x11) of paper with any notes you like. This exam has

More information

Midterm Exam 2 CS 455, Spring 2015

Midterm Exam 2 CS 455, Spring 2015 Name: USC NetId (e.g., ttrojan): Midterm Exam 2 CS 455, Spring 2015 April 7, 2015 There are 7 problems on the exam, with 60 points total available. There are 8 pages to the exam, including this one; make

More information

Midterm Exam CS 251, Intermediate Programming March 12, 2014

Midterm Exam CS 251, Intermediate Programming March 12, 2014 Midterm Exam CS 251, Intermediate Programming March 12, 2014 Name: NetID: Answer all questions in the space provided. Write clearly and legibly, you will not get credit for illegible or incomprehensible

More information

Programming with Java

Programming with Java Programming with Java Data Types & Input Statement Lecture 04 First stage Software Engineering Dep. Saman M. Omer 2017-2018 Objectives q By the end of this lecture you should be able to : ü Know rules

More information

Constants are named in ALL_CAPS, using upper case letters and underscores in their names.

Constants are named in ALL_CAPS, using upper case letters and underscores in their names. Naming conventions in Java The method signature Invoking methods All class names are capitalized Variable names and method names start with a lower case letter, but every word in the name after the first

More information

1.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 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 information

Midterm I Exam Principles of Imperative Computation André Platzer Ananda Gunawardena. February 23, Name: Andrew ID: Section:

Midterm I Exam Principles of Imperative Computation André Platzer Ananda Gunawardena. February 23, Name: Andrew ID: Section: Midterm I Exam 15-122 Principles of Imperative Computation André Platzer Ananda Gunawardena February 23, 2012 Name: Andrew ID: Section: Instructions This exam is closed-book with one sheet of notes permitted.

More information

Programming Languages and Techniques (CIS120)

Programming 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 information

Inheritance Motivation

Inheritance 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 information

PASS4TEST IT 인증시험덤프전문사이트

PASS4TEST IT 인증시험덤프전문사이트 PASS4TEST IT 인증시험덤프전문사이트 http://www.pass4test.net 일년동안무료업데이트 Exam : 1z0-809 Title : Java SE 8 Programmer II Vendor : Oracle Version : DEMO Get Latest & Valid 1z0-809 Exam's Question and Answers 1 from

More information

CSE 143 Lecture 14. Interfaces; Abstract Data Types (ADTs) reading: 9.5, 11.1; 16.4

CSE 143 Lecture 14. Interfaces; Abstract Data Types (ADTs) reading: 9.5, 11.1; 16.4 CSE 143 Lecture 14 Interfaces; Abstract Data Types (ADTs) reading: 9.5, 11.1; 16.4 slides adapted from Marty Stepp and Hélène Martin http://www.cs.washington.edu/143/ Related classes Consider classes for

More information