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

Size: px
Start display at page:

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

Transcription

1 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 no restriction on the paper-based items or items on a USB flash drive that the student may take into the examination. None CI101/2015/2016 Semester 1 Page 1 of 21 Printing date:05/12/2016

2 Section A Section A carries 50 marks in total. Use the application provided to record the answer for each multiple choice question (Question 1 Question 20) in section A of this exam paper. Remember to fill in your student number in the box provided for this (Highlighted initially with a reddish background) before existing from the application. Each question in Section A is worth 2.5 marks. Section A carries 50 marks in total. There is no penalty for answering a question wrongly. Question 1 class Main int page = 7; System.out.printf("Next page number = %2d\n", page + 1 ); When executed the above Java application will print: Next page number = 7 Next page number = 8 Next page number = Page + 1 A run time error message CI101/2015/2016 Semester 1 Page 2 of 21 Printing date:05/12/2016

3 Question 2 class Main int free_gb = 4; if ( free_gb < 4 ) System.out.println("Free memory low"); if ( free_gb > 8 ) System.out.println("Free memory high"); When executed the above Java application will print: No output will be produced Free memory low Free memory high Free memory low Free memory high CI101/2015/2016 Semester 1 Page 3 of 21 Printing date:05/12/2016

4 Question 3 class Main int value = 0; value = 7 / 2; System.out.println( value ); value = 3 + 1/2; System.out.println( value ); value = 3; int x = value; value = x++; System.out.println( value ); value = 10 % 7; System.out.println( value ); When executed the above Java application will: Print 3 once Print 3 two times Print 3 three times Print 3 four times. CI101/2015/2016 Semester 1 Page 4 of 21 Printing date:05/12/2016

5 Question 4 class Main int a = 1; int b = 2; int c = 3; if ( a!= b ) System.out.println("OK"); if ( a <= b ) System.out.println("OK"); if ( b <= c && b >= a ) System.out.println("OK"); if ( ( b <= c b >= a ) && true ) System.out.println("OK"); When executed the above Java application will: print OK once. print OK two times print OK three times print OK four times. CI101/2015/2016 Semester 1 Page 5 of 21 Printing date:05/12/2016

6 Question 5 class Main int a = 1; int b = 2; int c = 3; for ( int i = c; i < b; i++ ) System.out.println("OK"); for ( int i = a; i <= c; i++ ) System.out.println("OK"); When executed the above Java application will: print OK 2 times. print OK 3 times print OK 4 times print OK 5 times. CI101/2015/2016 Semester 1 Page 6 of 21 Printing date:05/12/2016

7 Question 6 class Main private static int year = 2016; if ( year > 2016 ) int year = 2015; int i=1; while ( i < 2 ) year += i; ++i; System.out.println( year ); After executing the above code the result printed will be: The program will not compile as the variable year is declared twice. When run, will produce no output CI101/2015/2016 Semester 1 Page 7 of 21 Printing date:05/12/2016

8 Question 7 In Java the variables of a class type are introduced by field declarations. Thus an instance of a class (an object) will hold storage for each non static field that is declared within the class. If the field declaration is static it will be class wide and only one instance of the field will be held. Which of the following are valid field declarations? Assume that any necessary imports of classes have been made. private final int LUCKY = 7 + 0; private static int state = 42; private ArrayList<String> names = new ArrayList<>();. All the above are valid field declarations Question 8 In Java what is the largest whole number that can be held in an instance of a short: None of the above. CI101/2015/2016 Semester 1 Page 8 of 21 Printing date:05/12/2016

9 Question 9 In the following Java program class Main int count = 0; // Java statement System.out.println( value ); Which of the following replacements for the line // Java statement Replacement Statement Java code S1 count++; S2 count = count + 1; S3 count += 1; S4 count =+ 1; will cause the value 1 to be printed when the modified program is compiled and run. Only replacement statements S1, S2 or S3 will cause 1 to be printed. Only replacement statements S2 or S4 will cause 1 to be printed. Only replacement statements S1, S3 or S4 will cause 1 to be printed. All statements (S1, S2, S3 or S4) will cause 1 to be printed. CI101/2015/2016 Semester 1 Page 9 of 21 Printing date:05/12/2016

10 Question 10 If the class Box and Main are declared as follows: class Box private int contents = 0; public int contents() return contents; public Box inc() contents++; return this; public Box dec() contents--; return this; class Main String s = new String(); Box mysterybox = new Box(); //new Box(); mysterybox.inc().inc().dec().inc(); System.out.println( mysterybox.contents() ); What would be printed if the above class Main was run as a program? CI101/2015/2016 Semester 1 Page 10 of 21 Printing date:05/12/2016

11 Question 11 Which of the following statements about the Java language is true? Using Java it is impossible to write an incorrect program. You can always rewrite a for statement as a while statement. An if statement must always have an else part. A switch statement must always have a default label. Question 12 Which of the following statements about the Java language is false? A method is invoked when you send a message to an object. An object is an instance of a class. Several objects may be instances of the same class. A class may not contain two or more methods with the same name. CI101/2015/2016 Semester 1 Page 11 of 21 Printing date:05/12/2016

12 Question 13 Which of the following statements about the Java language is true? An array may be extended by inserting a new element at the end. An array index goes from 1 to the number of items in the array. There is no way at run time of finding the number of elements in an array. You can not use as an index to an array that is an instance of the class String. Question 14 Which of the following statements about the Java language is true? An instance of the class String is immutable (can not be changed). System.out.println( "hello".touppercase() ); Will print Hello static int a = 2; In subsequent code the value of a may not be changed. char c = "Brighton".charAt("Brighton".length() ); Will put 'n' into the variable c. Question 15 Which of the following statements about the Java language is true? A constructor with no parameters must be explicitly defined in a class. A constructor must have a void return type. A class may have at most 1 (one) constructor. A constructor in a class must have the same name as the class in which it is part of. CI101/2015/2016 Semester 1 Page 12 of 21 Printing date:05/12/2016

13 Question 16 Which of the following statements about the Java language is true? You do not need to use the class construct in a Java program that only consists of a single line of Java code. The class construct in Java helps simplify the process of reusing code contained in an existing program by another program. In a Java program a primitive type may be used anywhere a reference type may be used. The == operator should be used when comparing instances of the class String. Question 17 Which of the following statements about the Java language is true? A private method is visible to a programmer, who wishes to call the method from code that resides outside of the class. All classes in Java must have a method with the signature: An import statement can occur anywhere within a Java program. A class may have an inner class. Question 18 The debugger provided with the BlueJ IDE (Integrated Development Environment) will: Helps find syntax errors in your program. Helps find compile time semantic errors in your program. Helps find run-time logical errors in your program. All of the above. CI101/2015/2016 Semester 1 Page 13 of 21 Printing date:05/12/2016

14 Question 19 Which of the following statements about the Java language is true? A shallow copy is performed when you assign an instance of a reference type. A byte is an example of a primitive type. An array is an example of a reference type. All of the above. Question 20 In relationship to the standard conventions used for writing a Java program which of the following is true? The convention is that a mutable (can be changed at run-time) variable name starts with a lower case letter. The convention is that a method name starts with a lower case letter. The convention is that a class starts with an upper case letter. All of the above. CI101/2015/2016 Semester 1 Page 14 of 21 Printing date:05/12/2016

15 Marks Section B Section B carries 50 marks Brief A Java application has been written to input an integer number which represents the width of an inverted pyramid. This pyramid made of stars is then printed against a background of dots. The width of the pyramid must be odd and greater than or equal to 7. If this is not true, then the error message Size must be odd or >= 7 is to be printed. Unfortunately the application contains in total 5 (Five) syntax, semantic or logical errors. Correct these errors in the application. Remember to only correct the errors and do not rewrite the program. A BlueJ project for this application named 2.1 is in the folder starting with ci101.exam at the top level on the h: drive. Using BlueJ correct these errors, so that the application produces the expected results. Example input data Commentary Example Input 7 Width of pyramid picture. Expected output *******.*****...***.....*... Special instructions Remember any line printed that contains a # will not be considered as part of your answer. This is so that you can write out a meaningful prompt for any data (containing a # character) and this line of text will be ignored in the comparison of your answer. The program A printed copy of the Java application for question 2.1 (that contains the errors mentioned above) is on the following page. P.T.O. CI101/2015/2016 Semester 1 Page 15 of 21 Printing date:05/12/2016

16 The program for Question 2.1 //Please enter your student number // in this comment here: class Main System.out.print("#Enter width of shape: "); int size = BIO.getInt(); if ( size%2!= 1 && size < 7 ) System.out.println("Size must be odd or >= 7" ); else for ( int i=1; i<= size/2; i++ ) print( '.', i ); print( '*', size-i*2 ); printnl( '.', i ); /** * Print the character c howmanytimes c The character to be printed howmanytimes How many times to print c */ public static void print( char c, int howmanytimes ) for ( int i=1; i<howmanytimes; i++ ) System.out.print( c ); /** * Print the character c howmanytimes followed by a newline c The character to be printed howmanytimes How many times to print c */ public static void printnl( char c, int howmanytimes ) print( c, howmany ); System.out.println(); CI101/2015/2016 Semester 1 Page 16 of 21 Printing date:05/12/2016

17 Marks Brief A Java application has been written to process data for units used by mobile phone users. Customers are charged a flat rate of 4p for each unit used. The data consists of: The mobile phone number The value of the last months units used The value of the current months units used The data is terminated with a mobile phone number of 0. The data is to be checked for potential problems and to highlight and report the number of problems found in the data. HIGH OK CHECK INACTIVE The data indicates that a high number of units have been used. High is defined as more than 1000 units used ( 40) The data looks normal. The data indicates that a negative amount of units have been used. The data indicates that the mobile phone has not been used. The results for each phone are reported on a single line, for example with the data: Then the result printed would be: Number Previous Current Used Comment CHECK Summary of phone data High = 0 OK = 0 Check = 1 Inactive = 0 Unfortunately the application contains (in total 5 errors) syntax, semantic and logic errors. A BlueJ project for this application named 2.2 is in the folder starting with ci101.exam at the top level on the h: drive. Using BlueJ correct these errors, so that the application produces the expected results. P.T.O. CI101/2015/2016 Semester 1 Page 17 of 21 Printing date:05/12/2016

18 Example Input Example input data Commentary Telephone number Previous reading Current reading Telephone number Previous reading Current reading Telephone number Previous reading Current reading Telephone number Previous reading Current reading Telephone number Previous reading Current reading Terminator Expected output Number Previous Current Used Comment OK OK HIGH INACTIVE CHECK Summary of phone data High = 1 OK = 2 Check = 1 Inactive = 1 Special instructions Remember any line printed that contains a # will not be considered as part of your answer. This is so that you can write out a meaningful prompt for any data (containing a # character) and this line of text will be ignored in the comparison of your answer. The program A printed copy of the Java application for question 2.2 (that contains the errors mentioned above) is on the following page. The format %010d in a printf statement means print an instance of a long (or value that can be converted to a long) in a field width of 10 with leading 0 s P.T.O. CI101/2015/2016 Semester 1 Page 18 of 21 Printing date:05/12/2016

19 The program for Question 2.2 class Main System.out.printf("%10s %8s %8s %8s %8s\n", "Number", "Previous", "Current", "Used", "Comment" ); System.out.print("#Enter phone number : " ); long number = BIO.getInt(); int high = 0, ok = 0, inactive = 0, check = 0; while ( number >= 0 ) System.out.print("#Enter previous reading: " ); int previous = BIO.getInt(); System.out.print("#Enter current reading : " ); int current = BIO.getInt(); int used = current - previous; System.out.printf("%010d %8d %8d ", number, previous, current ); if ( used > 0 ) if ( used >= 1000 ) System.out.printf( "%8d %8s", used, "HIGH" ); high++; else System.out.printf( "%8d %8s", used, "OK" ); ok--; else if ( used <= 0 ) System.out.printf("%8s %8s", "", "CHECK" ); check++; if ( used == 0 ) System.out.printf("%8s %8s", "", "INACTIVE" ); inactive++; System.out.println(); System.out.print("#Enter phone number : " ); number = BIO.getInt(); System.out.printf("Summary of phone data\n" + "High = %6d\nOK = %6d\n" + "Check = %6d\nInactive = %6d\n", high, OK, check, inactive ); CI101/2015/2016 Semester 1 Page 19 of 21 Printing date:05/12/2016

20 Marks Brief Write a Java application that reads in a value representing the width and height of a square picture that displays on a background of dots a cross made up symbols. The picture includes a frame of stars. This style of picture is often referred to as ASCII art. For example if the number input was 5 then the following picture would be displayed: ASCII art picture size 5 ***** *@.@* *.@.* *@.@* ***** If the input value is not an odd number, then the following error message (if for example 8 were input) would be displayed: Error size (8) must be an odd number If the input value is less than 0 then the following error message (if for example -81 were input) would be displayed: Error size (-81) must be greater than 0 The data is terminated by the number 0 (Zero). A BlueJ project for this application named 2.3 is in the folder starting with ci101.exam at the top level on the h: drive. Using BlueJ construct the application to produce the ASCII art picture. Example input data Example 1 Input 9 0 Expected output ASCII art picture size 1 * ASCII art picture size 9 ********* *@...@* *.@...@.* *..@.@..* *...@...* *..@.@..* *.@...@.* *@...@* ********* Commentary Size of square Size of square Terminator CI101/2015/2016 Semester 1 Page 20 of 21 Printing date:05/12/2016

21 Special instructions Remember any line printed that contains a # will not be considered as part of your answer. This is so that you can write out a meaningful prompt for any data (containing a # character) and this line of text will be ignored in the comparison of your answer. Remember, you must be able to draw the picture for any odd number greater than 0. CI101/2015/2016 Semester 1 Page 21 of 21 Printing date:05/12/2016

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

SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 2 EXAMINATIONS 2014/2015 CI101/CI101H. Programming s SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 2 EXAMINATIONS 2014/2015 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 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

In the following description the h: drive is used to indicate the directory in which during the actual ci101 exam the files used will reside.

In the following description the h: drive is used to indicate the directory in which during the actual ci101 exam the files used will reside. Important In the following description the h: drive is used to indicate the directory in which during the actual ci101 exam the files used will reside. However, if you are trying the exam system out yourself

More information

Section 2.2 Your First Program in Java: Printing a Line of Text

Section 2.2 Your First Program in Java: Printing a Line of Text Chapter 2 Introduction to Java Applications Section 2.2 Your First Program in Java: Printing a Line of Text 2.2 Q1: End-of-line comments that should be ignored by the compiler are denoted using a. Two

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

Section 2.2 Your First Program in Java: Printing a Line of Text

Section 2.2 Your First Program in Java: Printing a Line of Text Chapter 2 Introduction to Java Applications Section 2.2 Your First Program in Java: Printing a Line of Text 2.2 Q1: End-of-line comments that should be ignored by the compiler are denoted using a. Two

More information

Full file at

Full file at Chapter 2 Introduction to Java Applications Section 2.1 Introduction ( none ) Section 2.2 First Program in Java: Printing a Line of Text 2.2 Q1: End-of-line comments that should be ignored by the compiler

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

CS 139 Practice Midterm Questions #2

CS 139 Practice Midterm Questions #2 CS 139 Practice Midterm Questions #2 Spring 2016 Name: 1. Write Java statements to accomplish each of the following. (a) Declares numbers to be an array of int s. (b) Initializes numbers to contain a reference

More information

St. Edmund Preparatory High School Brooklyn, NY

St. Edmund Preparatory High School Brooklyn, NY AP Computer Science Mr. A. Pinnavaia Summer Assignment St. Edmund Preparatory High School Name: I know it has been about 7 months since you last thought about programming. It s ok. I wouldn t want to think

More information

McGill University School of Computer Science COMP-202A Introduction to Computing 1

McGill University School of Computer Science COMP-202A Introduction to Computing 1 McGill University School of Computer Science COMP-202A Introduction to Computing 1 Midterm Exam Thursday, October 26, 2006, 18:00-20:00 (6:00 8:00 PM) Instructors: Mathieu Petitpas, Shah Asaduzzaman, Sherif

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

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

Introduction to Java Applications

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

M105: Introduction to Programming with Java Midterm Examination (MTA) Makeup Spring 2013 / 2014

M105: Introduction to Programming with Java Midterm Examination (MTA) Makeup Spring 2013 / 2014 M105: Introduction to Programming with Java Midterm Examination (MTA) Makeup Spring 2013 / 2014 Question One: Choose the correct answer and write it on the external answer booklet. 1. Java is. a. case

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

Do not start the test until instructed to do so!

Do not start the test until instructed to do so! CS 1054: Programming in Java Page 1 of 6 Form A READ THIS NOW! Failure to read and follow the instructions below may result in severe penalties Failure to adhere to these directions will not constitute

More information

Superior University. Department of Electrical Engineering CS-115. Computing Fundamentals. Experiment No.5. for loop and do-while loop

Superior University. Department of Electrical Engineering CS-115. Computing Fundamentals. Experiment No.5. for loop and do-while loop Superior University Department of Electrical Engineering CS-115 Computing Fundamentals Experiment No.5 for loop and do-while loop Prepared for By: Name: ID: Section: Semester: Total Marks: Obtained Marks:

More information

Review for Test 1 (Chapter 1-5)

Review for Test 1 (Chapter 1-5) Review for Test 1 (Chapter 1-5) 1. Introduction to Computers, Programs, and Java a) What is a computer? b) What is a computer program? c) A bit is a binary digit 0 or 1. A byte is a sequence of 8 bits.

More information

Course Outline. Introduction to java

Course Outline. Introduction to java Course Outline 1. Introduction to OO programming 2. Language Basics Syntax and Semantics 3. Algorithms, stepwise refinements. 4. Quiz/Assignment ( 5. Repetitions (for loops) 6. Writing simple classes 7.

More information

CS 231 Data Structures and Algorithms, Fall 2016

CS 231 Data Structures and Algorithms, Fall 2016 CS 231 Data Structures and Algorithms, Fall 2016 Dr. Bruce A. Maxwell Department of Computer Science Colby College Course Description Focuses on the common structures used to store data and the standard

More information

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

University of Cape Town ~ Department of Computer Science. Computer Science 1015F ~ 2007 Name: Please fill in your Student Number and Name. Student Number : Student Number: University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ 2007 Final Examination Question Max

More information

Full file at

Full file at Chapter 1 Primitive Java Weiss 4 th Edition Solutions to Exercises (US Version) 1.1 Key Concepts and How To Teach Them This chapter introduces primitive features of Java found in all languages such as

More information

CMSC 132: Object-Oriented Programming II

CMSC 132: Object-Oriented Programming II CMSC 132: Object-Oriented Programming II Java Support for OOP Department of Computer Science University of Maryland, College Park Object Oriented Programming (OOP) OO Principles Abstraction Encapsulation

More information

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

C212 Early Evaluation Exam Mon Feb Name: Please provide brief (common sense) justifications with your answers below. C212 Early Evaluation Exam Mon Feb 10 2014 Name: Please provide brief (common sense) justifications with your answers below. 1. What is the type (and value) of this expression: 5 * (7 + 4 / 2) 2. What

More information

CS141 Programming Assignment #6

CS141 Programming Assignment #6 CS141 Programming Assignment #6 Due Sunday, Nov 18th. 1) Write a class with methods to do the following output: a) 5 5 5 5 5 4 4 4 4 3 3 3 2 2 1 b) 1 2 3 4 5 4 3 2 1 1 2 3 4 * 4 3 2 1 1 2 3 * * * 3 2 1

More information

2.8. Decision Making: Equality and Relational Operators

2.8. Decision Making: Equality and Relational Operators Page 1 of 6 [Page 56] 2.8. Decision Making: Equality and Relational Operators A condition is an expression that can be either true or false. This section introduces a simple version of Java's if statement

More information

BCIS 3630 Dr. GUYNES SPRING 2018 TUESDAY SECTION [JAN version] GRADER COURSE WEBSITE

BCIS 3630 Dr. GUYNES SPRING 2018 TUESDAY SECTION [JAN version] GRADER   COURSE WEBSITE COURSE WEBSITE http://www.steveguynes.com/bcis3630/bcis3630/default.html Instructor: Dr. Guynes Office: BLB 312H Phone: (940) 565-3110 Office Hours: By Email Email: steve.guynes@unt.edu TEXTBOOK: Starting

More information

5/3/2006. Today! HelloWorld in BlueJ. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont.

5/3/2006. Today! HelloWorld in BlueJ. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. Today! Build HelloWorld yourself in BlueJ and Eclipse. Look at all the Java keywords. Primitive Types. HelloWorld in BlueJ 1. Find BlueJ in the start menu, but start the Select VM program instead (you

More information

C0MP1911 Final Exam 1337 Computing 1

C0MP1911 Final Exam 1337 Computing 1 Family Name: Other Names: Signature: Student Number: This PAPER is NOT to be retained by the STUDENT The University Of New South Wales C0MP1911 Final Exam 1337 Computing 1 July 2006 Time allowed: 3 hrs

More information

In Java there are three types of data values:

In Java there are three types of data values: In Java there are three types of data values: primitive data values (int, double, boolean, etc.) arrays (actually a special type of object) objects An object might represent a string of characters, a planet,

More information

1.00 Introduction to Computers and Engineering Problem Solving. Quiz 1 March 7, 2003

1.00 Introduction to Computers and Engineering Problem Solving. Quiz 1 March 7, 2003 1.00 Introduction to Computers and Engineering Problem Solving Quiz 1 March 7, 2003 Name: Email Address: TA: Section: You have 90 minutes to complete this exam. For coding questions, you do not need to

More information

Building Java Programs Chapter 2

Building Java Programs Chapter 2 Building Java Programs Chapter 2 Primitive Data and Definite Loops Copyright (c) Pearson 2013. All rights reserved. Data types type: A category or set of data values. Constrains the operations that can

More information

This is a copy of the notes used in the module CI01.

This is a copy of the notes used in the module CI01. CI101 This is a copy of the notes used in the module CI01. It is presented to you in the hope that it will be useful and reduce some of the burden of taking notes during the lectures. However, it will

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

Introduction to the coursework for CI228

Introduction to the coursework for CI228 Introduction to the coursework for CI228 It is very unlikely that you would be able to complete this coursework without attending lectures and tutorials and following the suggested completion deadlines.

More information

COMP102: Test 1 Model Solutions

COMP102: Test 1 Model Solutions Family Name:.......................... Other Names:.......................... ID Number:............................ COMP102: Test 1 Model Solutions 27 July, 2007 Instructions Time allowed: 45 minutes.

More information

Do this by creating on the m: drive (Accessed via start menu link Computer [The m: drive has your login id as name]) the subdirectory CI101.

Do this by creating on the m: drive (Accessed via start menu link Computer [The m: drive has your login id as name]) the subdirectory CI101. Creating and running a Java program. This tutorial is an introduction to running a computer program written in the computer programming language Java using the BlueJ IDE (Integrated Development Environment).

More information

CS Introduction to Programming Midterm Exam #1 - Prof. Reed Spring 2009

CS Introduction to Programming Midterm Exam #1 - Prof. Reed Spring 2009 CS 102 - Introduction to Programming Midterm Exam #1 - Prof. Reed Spring 2009 What is your name?: There are two sections: I. True/False..................... 72 points; ( 36 questions, 2 points each) II.

More information

cis20.1 design and implementation of software applications I fall 2007 lecture # I.2 topics: introduction to java, part 1

cis20.1 design and implementation of software applications I fall 2007 lecture # I.2 topics: introduction to java, part 1 topics: introduction to java, part 1 cis20.1 design and implementation of software applications I fall 2007 lecture # I.2 cis20.1-fall2007-sklar-leci.2 1 Java. Java is an object-oriented language: it is

More information

Curriculum Map Grade(s): Subject: AP Computer Science

Curriculum Map Grade(s): Subject: AP Computer Science Curriculum Map Grade(s): 11-12 Subject: AP Computer Science (Semester 1 - Weeks 1-18) Unit / Weeks Content Skills Assessments Standards Lesson 1 - Background Chapter 1 of Textbook (Weeks 1-3) - 1.1 History

More information

An Introduction To Writing Your Own Classes CSC 123 Fall 2018 Howard Rosenthal

An Introduction To Writing Your Own Classes CSC 123 Fall 2018 Howard Rosenthal An Introduction To Writing Your Own Classes CSC 123 Fall 2018 Howard Rosenthal Lesson Goals Understand Object Oriented Programming The Syntax of Class Definitions Constructors this Object Oriented "Hello

More information

Objects and Classes -- Introduction

Objects and Classes -- Introduction Objects and Classes -- Introduction Now that some low-level programming concepts have been established, we can examine objects in more detail Chapter 4 focuses on: the concept of objects the use of classes

More information

Reminder the scope of a variable is the part of the program where that variable is visible Will this compile?

Reminder the scope of a variable is the part of the program where that variable is visible Will this compile? CS139 Nested Loops Loops and Scope Reminder the scope of a variable is the part of the program where that variable is visible Will this compile? while (number < 10) { String result = "latest " + number;

More information

Selected Questions from by Nageshwara Rao

Selected Questions from  by Nageshwara Rao Selected Questions from http://way2java.com by Nageshwara Rao Swaminathan J Amrita University swaminathanj@am.amrita.edu November 24, 2016 Swaminathan J (Amrita University) way2java.com (Nageshwara Rao)

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

1.00 Lecture 8. Using An Existing Class, cont.

1.00 Lecture 8. Using An Existing Class, cont. .00 Lecture 8 Classes, continued Reading for next time: Big Java: sections 7.9 Using An Existing Class, cont. From last time: is a Java class used by the BusTransfer class BusTransfer uses objects: First

More information

SAMPLE QUESTIONS FOR DIPLOMA IN INFORMATION TECHNOLOGY; YEAR 1

SAMPLE QUESTIONS FOR DIPLOMA IN INFORMATION TECHNOLOGY; YEAR 1 FACULTY OF SCIENCE AND TECHNOLOGY SAMPLE QUESTIONS FOR DIPLOMA IN INFORMATION TECHNOLOGY; YEAR 1 ACADEMIC SESSION 2014; SEMESTER 3 PRG102D: BASIC PROGRAMMING CONCEPTS Section A Compulsory section Question

More information

Name CIS 201 Midterm II: Chapters 1-8

Name 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 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 (C) 2010 Pearson Education, Inc. All rights reserved. Java application A computer program that executes when you use the java command to launch the Java Virtual Machine

More information

ICOM 4015 Advanced Programming Laboratory. Chapter 1 Introduction to Eclipse, Java and JUnit

ICOM 4015 Advanced Programming Laboratory. Chapter 1 Introduction to Eclipse, Java and JUnit ICOM 4015 Advanced Programming Laboratory Chapter 1 Introduction to Eclipse, Java and JUnit University of Puerto Rico Electrical and Computer Engineering Department by Juan E. Surís 1 Introduction This

More information

Ticket Machine Project(s)

Ticket Machine Project(s) Ticket Machine Project(s) Understanding the basic contents of classes Produced by: Dr. Siobhán Drohan (based on Chapter 2, Objects First with Java - A Practical Introduction using BlueJ, David J. Barnes,

More information

CSE 11 Midterm Fall 2008

CSE 11 Midterm Fall 2008 Signature cs11f Name Student ID CSE 11 Midterm Fall 2008 Page 1 (10 points) Page 2 (22 points) Page 3 (23 points) Page 4 (17 points) Page 5 (12 points) Total (84 points = 80 base points + 4 points EC [5%])

More information

COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand

COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand COSC 236 Web Site You will always find the course material at: http://www.class-notes.us From this site you can click on the COSC-236

More information

Key Differences Between Python and Java

Key Differences Between Python and Java Python Python supports many (but not all) aspects of object-oriented programming; but it is possible to write a Python program without making any use of OO concepts. Python is designed to be used interpretively.

More information

You will not be tested on JUnit or the Eclipse debugger. The exam does not cover interfaces.

You will not be tested on JUnit or the Eclipse debugger. The exam does not cover interfaces. Com S 227 Fall 2016 Topics and review problems for Exam 2 Thursday, November 10, 6:45 pm Locations, by last name: (same locations as Exam 1) A-C Curtiss 0127, first floor only D-N Hoover 2055 O-Z Troxel

More information

What we will do today Explain and look at examples of. Programs that examine data. Data types. Topic 4. variables. expressions. assignment statements

What we will do today Explain and look at examples of. Programs that examine data. Data types. Topic 4. variables. expressions. assignment statements Topic 4 Variables Once a programmer has understood the use of variables, he has understood the essence of programming -Edsger Dijkstra What we will do today Explain and look at examples of primitive data

More information

You must bring your ID to the exam.

You must bring your ID to the exam. Com S 227 Spring 2017 Topics and review problems for Exam 2 Monday, April 3, 6:45 pm Locations, by last name: (same locations as Exam 1) A-E Coover 2245 F-M Hoover 2055 N-S Physics 0005 T-Z Hoover 1213

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

Building Java Programs Chapter 2. bug. Primitive Data and Definite Loops. Copyright (c) Pearson All rights reserved. Software Flaw.

Building Java Programs Chapter 2. bug. Primitive Data and Definite Loops. Copyright (c) Pearson All rights reserved. Software Flaw. Building Java Programs Chapter 2 bug Primitive Data and Definite Loops Copyright (c) Pearson 2013. All rights reserved. 2 An Insect Software Flaw 3 4 Bug, Kentucky Bug Eyed 5 Cheesy Movie 6 Punch Buggy

More information

Building Java Programs Chapter 2

Building Java Programs Chapter 2 Building Java Programs Chapter 2 Primitive Data and Definite Loops Copyright (c) Pearson 2013. All rights reserved. bug 2 An Insect 3 Software Flaw 4 Bug, Kentucky 5 Bug Eyed 6 Cheesy Movie 7 Punch Buggy

More information

Getting started with Java

Getting started with Java Getting started with Java Magic Lines public class MagicLines { public static void main(string[] args) { } } Comments Comments are lines in your code that get ignored during execution. Good for leaving

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

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

Mobile Computing Professor Pushpendra Singh Indraprastha Institute of Information Technology Delhi Java Basics Lecture 02

Mobile Computing Professor Pushpendra Singh Indraprastha Institute of Information Technology Delhi Java Basics Lecture 02 Mobile Computing Professor Pushpendra Singh Indraprastha Institute of Information Technology Delhi Java Basics Lecture 02 Hello, in this lecture we will learn about some fundamentals concepts of java.

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

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

AL GHURAIR UNIVERSITY College of Computing. Objectives: Examples: if Single-Selection Statement CSC 209 JAVA I. week 3- Control Statements: Part I

AL GHURAIR UNIVERSITY College of Computing. Objectives: Examples: if Single-Selection Statement CSC 209 JAVA I. week 3- Control Statements: Part I AL GHURAIR UNIVERSITY College of Computing CSC 209 JAVA I week 3- Control Statements: Part I Objectives: To use the if and if...else selection statements to choose among alternative actions. To use the

More information

Logic & program control part 2: Simple selection structures

Logic & program control part 2: Simple selection structures Logic & program control part 2: Simple selection structures Summary of logical expressions in Java boolean expression means an expression whose value is true or false An expression is any valid combination

More information

Software and Programming 1

Software and Programming 1 Software and Programming 1 Lab 1: Introduction, HelloWorld Program and use of the Debugger 17 January 2019 SP1-Lab1-2018-19.pptx Tobi Brodie (tobi@dcs.bbk.ac.uk) 1 Module Information Lectures: Afternoon

More information

Name Section Number. CS210 Exam #4 *** PLEASE TURN OFF ALL CELL PHONES*** Practice

Name Section Number. CS210 Exam #4 *** PLEASE TURN OFF ALL CELL PHONES*** Practice Name Section Number CS210 Exam #4 *** PLEASE TURN OFF ALL CELL PHONES*** Practice All Sections Bob Wilson OPEN BOOK/OPEN NOTES You will have all 90 minutes until the start of the next class period. Spend

More information

COMP102: Test July, 2006

COMP102: Test July, 2006 Name:.................................. ID Number:............................ COMP102: Test 1 26 July, 2006 Instructions Time allowed: 45 minutes. Answer all the questions. There are 45 marks in total.

More information

Inf1-OOP. Encapsulation and Collections. Perdita Stevens, adapting earlier version by Ewan Klein. March 2, School of Informatics

Inf1-OOP. Encapsulation and Collections. Perdita Stevens, adapting earlier version by Ewan Klein. March 2, School of Informatics Inf1-OOP Encapsulation and Collections Perdita Stevens, adapting earlier version by Ewan Klein School of Informatics March 2, 2015 Encapsulation Accessing Data Immutability Enhanced for loop Collections

More information

Java Bytecode (binary file)

Java Bytecode (binary file) Java is Compiled Unlike Python, which is an interpreted langauge, Java code is compiled. In Java, a compiler reads in a Java source file (the code that we write), and it translates that code into bytecode.

More information

Outline. Object Oriented Programming. Course goals. Staff. Course resources. Assignments. Course organization Introduction Java overview Autumn 2003

Outline. Object Oriented Programming. Course goals. Staff. Course resources. Assignments. Course organization Introduction Java overview Autumn 2003 Outline Object Oriented Programming Autumn 2003 2 Course goals Software design vs hacking Abstractions vs language (syntax) Java used to illustrate concepts NOT a course about Java Prerequisites knowledge

More information

SSOL Language Reference Manual

SSOL Language Reference Manual SSOL Language Reference Manual Madeleine Tipp Jeevan Farias Daniel Mesko mrt2148 jtf2126 dpm2153 Manager Language Guru System Architect October 15, 2018 Contents 1 Lexical Conventions 2 1.1 Identifiers...............................................

More information

CS Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2009

CS Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2009 CS 102 - Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2009 What is your name?: There are two sections: I. True/False..................... 60 points; ( 30 questions, 2 points each) II.

More information

M257 Putting Java to work

M257 Putting Java to work Arab Open University Faculty of Computer Studies Course Examination Spring 2010 M257 Putting Java to work Exam date: May 2010 Time allowed: 2.5 hours Form: X A B Student name/ Section number: Tutor Name:

More information

COMP 401 Spring 2013 Midterm 1

COMP 401 Spring 2013 Midterm 1 COMP 401 Spring 2013 Midterm 1 I have not received nor given any unauthorized assistance in completing this exam. Signature: Name: PID: Please be sure to put your PID at the top of each page. This page

More information

AP Computer Science Summer Work Mrs. Kaelin

AP Computer Science Summer Work Mrs. Kaelin AP Computer Science Summer Work 2018-2019 Mrs. Kaelin jkaelin@pasco.k12.fl.us Welcome future 2018 2019 AP Computer Science Students! I am so excited that you have decided to embark on this journey with

More information

Semester 1 CI101/CI177. Java

Semester 1 CI101/CI177. Java Semester 1 CI101/CI177 Java Object oriented programming M A Smith University of Brighton March 20, 2017 Page 1 This is a copy of the notes used in the module CI01. It is presented to you in the hope that

More information

Solutions to Quiz 1 (March 14, 2016)

Solutions to Quiz 1 (March 14, 2016) MIT 6.005: Software Construction Max Goldman revised Wednesday 16 th March, 2016, 14:08 Solutions to Quiz 1 (March 14, 2016) Problem 1 (Multiple Choice) (20 points). (a) Which of the following must be

More information

CS111: PROGRAMMING LANGUAGE II

CS111: PROGRAMMING LANGUAGE II 1 CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1: Introduction Lecture Contents 2 Course info Why programming?? Why Java?? Write once, run anywhere!! Java basics Input/output Variables

More information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

Objects and Classes Lecture 2

Objects and Classes Lecture 2 Objects and Classes Lecture 2 Waterford Institute of Technology January 12, 2016 John Fitzgerald Waterford Institute of Technology, Objects and ClassesLecture 2 1/32 Classes and Objects Example of class

More information

Data Structures. Data structures. Data structures. What is a data structure? Simple answer: a collection of data equipped with some operations.

Data Structures. Data structures. Data structures. What is a data structure? Simple answer: a collection of data equipped with some operations. Data Structures 1 Data structures What is a data structure? Simple answer: a collection of data equipped with some operations. Examples Lists Strings... 2 Data structures In this course, we will learn

More information

Datatypes, Variables, and Operations

Datatypes, Variables, and Operations Datatypes, Variables, and Operations 1 Primitive Type Classification 2 Numerical Data Types Name Range Storage Size byte 2 7 to 2 7 1 (-128 to 127) 8-bit signed short 2 15 to 2 15 1 (-32768 to 32767) 16-bit

More information

Basics of programming

Basics of programming 0. Java summary Core char int double boolean short long float primitive types; int a = 2; int b = 2, c = 4; Declaration of a variable a = b; a = b + c; Assignment b + c; // Addition b - c; // Subtraction

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

CS 177 Week 15 Recitation Slides. Review

CS 177 Week 15 Recitation Slides. Review CS 177 Week 15 Recitation Slides Review 1 Announcements Final Exam on Friday Dec. 18 th STEW 183 from 1 3 PM Complete your online review of your classes. Your opinion matters!!! Project 6 due Just kidding

More information

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

if (x == 0); System.out.println( x=0 ); if (x = 0) System.out.println( x=0 ); Sample Final Exam 1. Evaluate each of the following expressions and show the result and data type of each: Expression Value Data Type 14 % 5 1 / 2 + 1 / 3 + 1 / 4 4.0 / 2.0 Math.pow(2.0, 3.0) (double)(2

More information

EC312 Chapter 4: Arrays and Strings

EC312 Chapter 4: Arrays and Strings Objectives: (a) Describe how an array is stored in memory. (b) Define a string, and describe how strings are stored. EC312 Chapter 4: Arrays and Strings (c) Describe the implications of reading or writing

More information

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14 C introduction Variables Variables 1 / 14 Contents Variables Data types Variable I/O Variables 2 / 14 Usage Declaration: t y p e i d e n t i f i e r ; Assignment: i d e n t i f i e r = v a l u e ; Definition

More information

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 05 I/O statements Printf, Scanf Simple

More information

Introduction to Java & Fundamental Data Types

Introduction to Java & Fundamental Data Types Introduction to Java & Fundamental Data Types LECTURER: ATHENA TOUMBOURI How to Create a New Java Project in Eclipse Eclipse is one of the most popular development environments for Java, as it contains

More information

CSCE 145 Exam 1 Review. This exam totals to 100 points. Follow the instructions. Good luck!

CSCE 145 Exam 1 Review. This exam totals to 100 points. Follow the instructions. Good luck! CSCE 145 Exam 1 Review This exam totals to 100 points. Follow the instructions. Good luck! Chapter 1 This chapter was mostly terms so expect a fill in the blank style questions on definition. Remember

More information

CS141 Programming Assignment #8

CS141 Programming Assignment #8 CS141 Programming Assignment #8 Due Sunday, April 14th. 1- Write a class with methods to do the following output: a) 5 5 5 5 5 4 4 4 4 3 3 3 2 2 1 b) 1 2 3 4 5 4 3 2 1 1 2 3 4 * 4 3 2 1 1 2 3 * * * 3 2

More information

Lecture Notes for CS 150 Fall 2009; Version 0.5

Lecture Notes for CS 150 Fall 2009; Version 0.5 for CS 150 Fall 2009; Version 0.5 Draft! Do not distribute without prior permission. Copyright 2001-2009 by Mark Holliday Comments, corrections, and other feedback appreciated holliday@email.wcu.edu Chapter

More information

ECE264 Fall 2013 Exam 3, November 20, 2013

ECE264 Fall 2013 Exam 3, November 20, 2013 ECE264 Fall 2013 Exam 3, November 20, 2013 In signing this statement, I hereby certify that the work on this exam is my own and that I have not copied the work of any other student while completing it.

More information

CpSc 1111 Lab 4 Formatting and Flow Control

CpSc 1111 Lab 4 Formatting and Flow Control CpSc 1111 Lab 4 Formatting and Flow Control Overview By the end of the lab, you will be able to: use fscanf() to accept a character input from the user and print out the ASCII decimal, octal, and hexadecimal

More information