SFWR ENG/COMP SCI 2S03 Principles of Programming SOLUTIONS
|
|
- Jody Robbins
- 5 years ago
- Views:
Transcription
1 SFWR ENG/COMP SCI 2S03 Principles of Programming SOLUTIONS Day Class Midterm Exam Dr. R. Khedri DURATION : 50 minutes McMaster University Midterm Exam (CAS) October 29, 2012 Please CLEARLY print: NAME: Student ID: question mark out of total This examination paper includes 12 pages and 17 questions. You are responsible for ensuring that your copy of the paper is complete. Bring any discrepancy to the attention of your invigilator. Special Instructions : 1. The multiple-choice questions of this test must be answered on the McMaster standard OMR answer sheet (bubble form). The forms will be evaluated using McMaster optical scanner (OMR). The OMR instructions are on the next page. 2. The written questions must be answered in the space provided in this questionnaire. 3. Documents to be returned: this questionnaire, the OMR answer sheet, and all scrap paper if used. All of these documents must bear your name and student number. Only the face page of the questionnaire need to bear your name and student number, and all the loose pages of the questionnaire, if any. 4. No memory aids or textbooks of any kind are allowed during the test. No calculators, pocket computers, or PDA s are to be utilized. 5. No unauthorized scrap paper, crib sheets etc. are allowed to be used. The invigilator(s) will supply you with needed scrap paper when you ask. 6. You are not allowed to be involved in any communication of any kind concerning the questions and answers of this test with anybody except the invigilator(s) or the instructor. Any attempt of such communication will be considered a case of academic dishonesty. 7. The burden of communication is upon you. Solutions not properly explained will not be considered correct. Part of proper communication is the appearance and layout. If we cannot decode what you wrote, we cannot grade it as a correct answer. 1
2 SFWR ENG/COMP SCI 2S03 SOLUTIONS 2/12 OMR EXAMINATION - STUDENT INSTRUCTIONS NOTE: IT IS YOUR RESPONSIBILITY TO ENSURE THAT THE ANSWER SHEET IS PROPERLY COMPLETED: YOUR EXAMINATION RESULT DEPENDS UPON PROPER ATTENTION TO THESE INSTRUCTIONS. The scanner, which reads the sheets, senses the shaded areas by their non-reflection of light. A heavy mark must be made, completely filling the circular bubble, with an HB pencil. Marks made with a pen or felt-tip marker will NOT be sensed. Erasures must be thorough or the scanner may still sense a mark. Do NOT use correction fluid on the sheets. Do NOT put any unnecessary marks or writing on the sheets. 1. Print your name, student number, course name, section number and the date in the space provided at the top of Side 1 (red side) of the form. Then the sheet MUST be signed in the space marked SIGNATURE. 2. Mark your student number in the space provided on the sheet on Side 1 and fill in the corresponding bubbles underneath. 3. Mark only ONE choice from the alternatives (1,2,3,4,5, or A,B,C,D,E) provided for each question. If there is a True/False question, enter response 1 (or A) as True, and 2 (or B) as False. The question number is to the left of the bubbles. Make sure that the number of the question on the scan sheet is the same as the question number on the examination paper. 4. Pay particular attention to the Marking Directions on the form. 5. Begin answering questions using the first set of bubbles, marked "1". A picture of the answer sheet continued on page 3
3 SFWR ENG/COMP SCI 2S03 SOLUTIONS 3/12 In all the questions, we are considering Java programming language. Question 1 [1 mark] Given two boolean variables a and b, which one among the following is equivalent to the following expression?! (a && b) 1.! a &&! b 2.! a == b 3! a! b 4.! a ==! b Question 2 [1 mark] Which one of the following identifiers is valid? 1. /*a 2 salesprofit 3. int 4. double-points Question 3 [1 mark] How do we compare the value of two String objects in Java? 1. using the = operator 2. using the == operator 3 using the equals method 4. using the operator Question 4 [1 mark] What is the keyword used to instantiate an object in Java? 1. make 2. construct 3. instantiate(object) 4 new continued on page 4
4 SFWR ENG/COMP SCI 2S03 SOLUTIONS 4/12 Question 5 [1 mark] 1 p u b l i c c l a s s QuestionOne { p u b l i c s t a t i c void main ( S t r i n g [ ] args ) { 3 double length = 2. 0 ; double breadth = 4. 2 ; 5 double area = l e n g t h ( i n t ) breadth ; System. out. p r i n t f ( A r e c t a n g l e o f length %.2 f cm and breadth %.2 f cm + has area %.2 f sq. cm.%n, length, breadth, area ) ; 7 Which one among the following is the output of the above program? 1. A rectangle of length 2.00 cm and breadth 4.20 cm has area 8.40 sq. cm. 2. A rectangle of length cm and breadth cm has area sq. cm. 3. A rectangle of length 2 cm and breadth cm has area sq. cm. 4 A rectangle of length 2.00 cm and breadth 4.20 cm has area 8.00 sq. cm. Question 6 [1 mark] Which one of the following is NOT an existing wrapper class? 1. Integer 2 Char 3. Boolean 4. Double 5. Byte Question 7 [1 mark] interface (API): In a class called Test, a method foo has the following application programming public static void foo(); How would you call that method? 1 Test.foo(); 2. Test.foo(void); 3. foo.test(); 4. foo(test(void)); continued on page 5
5 SFWR ENG/COMP SCI 2S03 SOLUTIONS 5/12 Question 8 [1 mark] interface (API): In a class called Test, a method foo has the following application programming public double foo(int i, String s, char c); What is the return type of the method foo? 1 double 2. int 3. char 4. String Question 9 [1 mark] p u b l i c c l a s s QuestionTwo { 2 p u b l i c s t a t i c void main ( S t r i n g [ ] args ) { i n t a = 3 2 ; 4 i f ( a = 31) { System. out. p r i n t l n ( The value o f a i s 31 ) ; 6 e l s e { System. out. p r i n t l n ( The value o f a i s not 31 ) ; 8 10 At compile time, you get the following error: found : int required: boolean if (a = 31) { ^ 1 error Among the following, indicate the action that fixes the problem. 1. We chance the type of a to be boolean. 2. We change int a = 32; that is on Line 3 of the program to int a = boolean 32;. 3. We remove the curly brackets before and after the keyword else. 4. We change int a = 32; that is on Line 3 of the program to int a = = 32;. 5 None of the above continued on page 6
6 SFWR ENG/COMP SCI 2S03 SOLUTIONS 6/12 Question 10 [1 mark] If you want to execute a loop body at least once, what type of loop is the most appropriate than the others? 1. for loop 2. while loop 3. while loop with a counter starting with the value 1 4 do-while loop Question 11 [1 mark] statements? How many objects of the class CD exist after the execution of the following CD cd1 = new CD(); CD cd2 = cd1; 1. Two objects 2. Three objects 3. A very large number of objects 4. Zero objects 5 None of the above Question 12 [1 mark] What will the following statement print? System.out.println( ); None of the above continued on page 7
7 SFWR ENG/COMP SCI 2S03 SOLUTIONS 7/12 Question 13 [1 mark] Given the following declarations, which statement will not compile? int ival; double dval; Integer iref; Double dref; 1. iref = 12; 2. ival = iref; 3. dval = iref; 4 dref = 12; Question 14 [1 mark] p u b l i c c l a s s QuestionThree { 2 p u b l i c s t a t i c void main ( S t r i n g [ ] args ) { i n t i ; 4 double j = ; i = ( i n t ) ( j / 6) ; 6 i n t sum = 0 ; 8 while ( ( i % 10)!= 0) { sum += i ; 10 i ++; System. out. p r i n t f ( The value o f i i s %d and the value o f sum i s %d%n, i, sum) ; Which one of the following is the correct output of the above program? 1. The value of i is 10 and the value of sum is The value of i is 11 and the value of sum is 40 3 The value of i is 10 and the value of sum is The value of i is and the value of sum is continued on page 8
8 SFWR ENG/COMP SCI 2S03 SOLUTIONS 8/12 Question 15 [1 mark] 1 import java. u t i l. Scanner ; p u b l i c c l a s s QuestionSix { Consider the following program QuestionSix.java. 3 p u b l i c s t a t i c void main ( S t r i n g [ ] args ) { Scanner keyboard = new Scanner ( System. i n ) ; 5 System. out. p r i n t ( Enter the month number : ) ; i n t month = keyboard. nextint ( ) ; 7 S t r i n g monthstring ; switch ( month ) { 9 case 1 : monthstring = January ; break ; 11 case 2 : monthstring = February ; break ; 13 case 3 : monthstring = March ; break ; 15 case 4 : monthstring = April ; break ; 17 case 5 : monthstring = May ; break ; 19 d e f a u l t : a s s e r t ( month > 6) : The a s s e r t i o n i s t r i g g e r e d ; monthstring = We only handle months u n t i l 6 ; 21 break ; 23 System. out. p r i n t l n ( monthstring ) ; 25 Which one among the following is the most appropriate assessment of the above program: 1. The program does not compile due to a problem with the assertion. 2. When executed using the command java -ea QuestionSix, the program terminates without any problem for any entered integer value. 3 When executed using the command java -ea QuestionSix, the program terminates with an error message and that for some values of the variable month. 4. The program never terminates without run-time error. continued on page 9
9 SFWR ENG/COMP SCI 2S03 SOLUTIONS 9/12 Answer the two following questions in the allocated space within the corresponding program code Question 16 [3 marks] Fill in the needed code such that the program takes integer values as input from the user and finds the sum of those integers until the user types in the value -1 (which is not added). import java.util.scanner; public class QuestionFour { public static void main(string[] args) { Scanner keyboard = new Scanner(System.in); System.out.print("Enter an integer value, " + "enter -1 to stop: "); int value = keyboard.nextint(); // YOUR CODE GOES BELOW in the allocated space ANSWER: continued on page 10
10 SFWR ENG/COMP SCI 2S03 SOLUTIONS 10/12 1 import java. u t i l. Scanner ; p u b l i c c l a s s QuestionFour { 3 p u b l i c s t a t i c void main ( S t r i n g [ ] args ) { Scanner keyboard = new Scanner ( System. in ) ; 5 System. out. p r i n t ( Enter an i n t e g e r value, + e n t e r 1 to stop : ) ; i n t value = keyboard. nextint ( ) ; 7 // YOUR CODE GOES BELOW i n t sum = 0 ; 9 while ( value!= 1) { 11 sum += value ; System. out. p r i n t ( Enter an i n t e g e r value, + e n t e r 1 to stop : ) ; 13 value = keyboard. nextint ( ) ; System. out. p r i n t f ( The value o f value i s %d and the value o f sum i s %d %n, value, sum) ; continued on page 11
11 SFWR ENG/COMP SCI 2S03 SOLUTIONS 11/12 Question 17 [4 marks] Fill in the needed code such that the program prompts a user for a password. If it matches either admin or guest, then the corresponding verification success message is displayed. If it does not match, then a fail message is displayed. The user is given 3 attempts to try. If all 3 attempts fail then an all-fail message is displayed. import java.util.scanner; class PasswordVerifier { static final String ADMIN_PASSWORD = "admin"; static final String GUEST_PASSWORD = "guest"; static final int NUM_OF_ATTEMPTS = 3; public static void main(string args[]) { int attempts = NUM_OF_ATTEMPTS; String userpassword; Boolean passed = false; // If verification has succeeded. Scanner keyboard = new Scanner(System.in); // Input scanner. // Print welcome message. System.out.println("Welcome to The Password Verifier"); // Prompt user for password repeatedly until verified or out of attempts. // YOUR CODE GOES BELOW in the allocated space // Check if all attempts failed if (!passed) { System.out.println("All verification attempts failed!"); ANSWER: continued on page 12
12 SFWR ENG/COMP SCI 2S03 SOLUTIONS 12/12 / 2 =========================================================================== This Java program prompts a user f o r a password. I f i t matches e i t h e r 4 ADMIN PASSWORD or GUEST PASSWORD, then the corresponding v e r i f i c a t i o n succ es s message i s displayed. I f i t does not match, then a f a i l message i s 6 displayed. The user i s given 3 attempts to try. I f a l l 3 attempts f a i l then an a l l f a i l message i s d i s p l a y e d. 8 Written by : Tian Zhang October, =========================================================================== / import java. u t i l. Scanner ; c l a s s P a s s w o r d V e r i f i e r { s t a t i c f i n a l S t r i n g ADMIN PASSWORD = admin ; 18 s t a t i c f i n a l S t r i n g GUEST PASSWORD = guest ; s t a t i c f i n a l i n t NUM OF ATTEMPTS = 3 ; p u b l i c s t a t i c void main ( S t r i n g args [ ] ) { i n t attempts = NUM OF ATTEMPTS; 24 S t r i n g userpassword ; Boolean passed = f a l s e ; // I f v e r i f i c a t i o n has succeeded. 26 Scanner keyboard = new Scanner ( System. in ) ; // Input scanner. 28 // Print welcome message. 30 System. out. p r i n t l n ( Welcome to The Password V e r i f i e r ) ; System. out. p r i n t l n ( ) ; // Prompt user f o r password r e p e a t e d l y u n t i l v e r i f i e d or out o f attempts. while (! passed && attempts > 0) { System. out. print ( Please Enter the password ( + 38 attempts + attempt ( s ) l e f t ) : ) ; userpassword = keyboard. next ( ) ; 40 i f ( userpassword. equals (ADMIN PASSWORD) ) { 42 System. out. p r i n t l n ( V e r i f i e d as a d m i n i s t r a t o r! ) ; passed = true ; 44 e l s e { i f ( userpassword. equals (GUEST PASSWORD) ) { 46 System. out. p r i n t l n ( V e r i f i e d as guest! ) ; passed = true ; 48 e l s e { System. out. p r i n t l n ( V e r i f i c a t i o n f a i l e d! ) ; 50 attempts = attempts 1 ; // Check i f a l l attempts f a i l e d 58 i f (! passed ) { 60 System. out. p r i n t l n ( All v e r i f i c a t i o n attempts f a i l e d! ) ; THE END.
Computer Science 3CN3 and Software Engineering 4C03 Final Exam Answer Key
Computer Science 3CN3 and Software Engineering 4C03 Final Exam Answer Key DAY CLASS Dr. William M. Farmer DURATION OF EXAMINATION: 2 Hours MCMASTER UNIVERSITY FINAL EXAMINATION April 2008 THIS EXAMINATION
More informationMidterm Examination (MTA)
M105: Introduction to Programming with Java Midterm Examination (MTA) Spring 2013 / 2014 Question One: [6 marks] Choose the correct answer and write it on the external answer booklet. 1. Compilers and
More informationExam 2. Programming I (CPCS 202) Instructor: M. G. Abbas Malik. Total Marks: 40 Obtained Marks:
كلية الحاسبات وتقنية المعلوما Exam 2 Programming I (CPCS 202) Instructor: M. G. Abbas Malik Date: November 22, 2015 Student Name: Student ID: Total Marks: 40 Obtained Marks: Instructions: Do not open this
More informationNew York University Introduction to Computer Science Exam Sample Problems 2013 Andrew I. Case. Instructions:
Name: New York University Introduction to Computer Science Exam Sample Problems 2013 Andrew I. Case Instructions: KEEP TEST BOOKLET CLOSED UNTIL YOU ARE INSTRUCTED TO BEGIN. This exam is double sided (front
More informationProgramming 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 informationLoops. CSE 114, Computer Science 1 Stony Brook University
Loops CSE 114, Computer Science 1 Stony Brook University http://www.cs.stonybrook.edu/~cse114 1 Motivation Suppose that you need to print a string (e.g., "Welcome to Java!") a user-defined times N: N?
More informationThe for Loop, Accumulator Variables, Seninel Values, and The Random Class. CS0007: Introduction to Computer Programming
The for Loop, Accumulator Variables, Seninel Values, and The Random Class CS0007: Introduction to Computer Programming Review General Form of a switch statement: switch (SwitchExpression) { case CaseExpression1:
More informationNew York University Introduction to Computer Science Exam Sample Problems 2013 Andrew I. Case. Instructions:
Name: New York University Introduction to Computer Science Exam Sample Problems 2013 Andrew I. Case Instructions: KEEP TEST BOOKLET CLOSED UNTIL YOU ARE INSTRUCTED TO BEGIN. This exam is double sided (front
More informationMcGill 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 informationLoops. GEEN163 Introduction to Computer Programming
Loops GEEN163 Introduction to Computer Programming Simplicity is prerequisite for reliability. Edsger W. Dijkstra Programming Assignment A new programming assignment has been posted on Blackboard for this
More informationCOMP-202B - Introduction to Computing I (Winter 2011) - All Sections Example Questions for In-Class Quiz
COMP-202B - Introduction to Computing I (Winter 2011) - All Sections Example Questions for In-Class Quiz The in-class quiz is intended to give you a taste of the midterm, give you some early feedback about
More informationJava Foundations: Introduction to Program Design & Data Structures, 4e John Lewis, Peter DePasquale, Joseph Chase Test Bank: Chapter 2
Java Foundations Introduction to Program Design and Data Structures 4th Edition Lewis TEST BANK Full download at : https://testbankreal.com/download/java-foundations-introduction-toprogram-design-and-data-structures-4th-edition-lewis-test-bank/
More informationAnatomy of a Java Program: Comments
CS149 Anatomy of a Java Program: Comments Javadoc comments: /** * Application that converts inches to centimeters. * * @author Alvin Chao * @version 01/21/2014 */ Everything between /** and */ ignored
More informationChapter 5 Lab Methods
Chapter 5 Lab Methods Lab Objectives Be able to write methods Be able to call methods Be able to write javadoc comments Be able to create HTML documentation using the javadoc utility Introduction Methods
More informationFaculty of Science COMP-202A - Foundations of Computing (Fall 2012) - All Sections Midterm Examination
First Name: Last Name: McGill ID: Section: Faculty of Science COMP-202A - Foundations of Computing (Fall 2012) - All Sections Midterm Examination November 7th, 2012 Examiners: Daniel Pomerantz [Sections
More informationComputational Expression
Computational Expression Variables, Primitive Data Types, Expressions Janyl Jumadinova 28-30 January, 2019 Janyl Jumadinova Computational Expression 28-30 January, 2019 1 / 17 Variables Variable is a name
More informationM105: 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 informationFaculty of Science COMP-202A - Foundations of Computing (Fall 2013) - All Sections Midterm Examination
First Name: Last Name: McGill ID: Section: Faculty of Science COMP-202A - Foundations of Computing (Fall 2013) - All Sections Midterm Examination November 11th, 2013 Examiners: Jonathan Tremblay [Sections
More informationLecture 8 " INPUT " Instructor: Craig Duckett
Lecture 8 " INPUT " Instructor: Craig Duckett Assignments Assignment 2 Due TONIGHT Lecture 8 Assignment 1 Revision due Lecture 10 Assignment 2 Revision Due Lecture 12 We'll Have a closer look at Assignment
More informationSelec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Spring 2016 Howard Rosenthal
Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Spring 2016 Howard Rosenthal Lesson Goals Understand Control Structures Understand how to control the flow of a program
More information! definite loop: A loop that executes a known number of times. " The for loops we have seen so far are definite loops. ! We often use language like
Indefinite loops while loop! indefinite loop: A loop where it is not obvious in advance how many times it will execute.! We often use language like " "Keep looping as long as or while this condition is
More informationSection 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 informationFundamentals of Programming Data Types & Methods
Fundamentals of Programming Data Types & Methods By Budditha Hettige Overview Summary (Previous Lesson) Java Data types Default values Variables Input data from keyboard Display results Methods Operators
More informationProblem Solving With Loops
To appreciate the value of loops, take a look at the following example. This program will calculate the average of 10 numbers input by the user. Without a loop, the three lines of code that prompt the
More informationObject Oriented Programming. Java-Lecture 6 - Arrays
Object Oriented Programming Java-Lecture 6 - Arrays Arrays Arrays are data structures consisting of related data items of the same type In Java arrays are objects -> they are considered reference types
More informationCheck out how to use the random number generator (introduced in section 4.11 of the text) to get a number between 1 and 6 to create the simulation.
Chapter 4 Lab Loops and Files Lab Objectives Be able to convert an algorithm using control structures into Java Be able to write a while loop Be able to write an do-while loop Be able to write a for loop
More informationCIS 110 Introduction To Computer Programming. February 29, 2012 Midterm
CIS 110 Introduction To Computer Programming February 29, 2012 Midterm Name: Recitation # (e.g. 201): Pennkey (e.g. bjbrown): My signature below certifies that I have complied with the University of Pennsylvania
More informationCS 152: Data Structures with Java Hello World with the IntelliJ IDE
CS 152: Data Structures with Java Hello World with the IntelliJ IDE Instructor: Joel Castellanos e-mail: joel.unm.edu Web: http://cs.unm.edu/~joel/ Office: Electrical and Computer Engineering building
More informationSupplementary 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 informationComputer Programming, I. Laboratory Manual. Experiment #3. Selections
Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Experiment #3
More informationCSC 1051 Algorithms and Data Structures I. Midterm Examination February 24, Name: KEY 1
CSC 1051 Algorithms and Data Structures I Midterm Examination February 24, 2014 Name: KEY 1 Question Value Score 1 10 2 10 3 10 4 10 5 10 6 10 7 10 8 10 9 10 10 10 TOTAL 100 Please answer questions in
More informationSelec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal
Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal Lesson Goals Understand Control Structures Understand how to control the flow of a program
More informationIntroduction to Computer Science Unit 2. Notes
Introduction to Computer Science Unit 2. Notes Name: Objectives: By the completion of this packet, students should be able to describe the difference between.java and.class files and the JVM. create and
More informationFormatted Output / User IO
/ User IO 1 / 22 / User IO COMP SCI / SFWR ENG 2S03 Natalie Perna Dylan Aspden Department of Computing and Software McMaster University Week 4: Sept 29 - Oct 3 Natalie Perna, Dylan Aspden / User IO 1 /
More informationCMPS 12A Winter 2006 Prof. Scott A. Brandt Final Exam, March 21, Name:
CMPS 12A Winter 2006 Prof. Scott A. Brandt Final Exam, March 21, 2006 Name: Email: This is a closed note, closed book exam. There are II sections worth a total of 200 points. Plan your time accordingly.
More informationCS111: 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 informationCIS 110 Fall 2014 Introduction to Computer Programming 8 Oct 2014 Midterm Exam Name:
CIS 110 Fall 2014 Introduction to Computer Programming 8 Oct 2014 Midterm Exam Name: Recitation # (e.g., 201): Pennkey (e.g., eeaton): My signature below certifies that I have complied with the University
More information1. [3 pts] What is your section number, the period your discussion meets, and the name of your discussion leader?
CIS 3022 Prog for CIS Majors I February 10, 2009 Exam I Print Your Name Your Section # Total Score Your work is to be done individually. The exam is worth 105 points (five points of extra credit are available
More informationIntroduction to Computer Science Unit 2. Exercises
Introduction to Computer Science Unit 2. Exercises Note: Curly brackets { are optional if there is only one statement associated with the if (or ) statement. 1. If the user enters 82, what is 2. If the
More informationExample Program. public class ComputeArea {
COMMENTS While most people think of computer programs as a tool for telling computers what to do, programs are actually much more than that. Computer programs are written in human readable language for
More informationCSE 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 informationPractice Midterm 1. Problem Points Score TOTAL 50
CS 120 Software Design I Spring 2019 Practice Midterm 1 University of Wisconsin - La Crosse February 25 NAME: Do not turn the page until instructed to do so. This booklet contains 10 pages including the
More informationAP CS Unit 3: Control Structures Notes
AP CS Unit 3: Control Structures Notes The if and if-else Statements. These statements are called control statements because they control whether a particular block of code is executed or not. Some texts
More informationCSC 1051 Algorithms and Data Structures I. Midterm Examination February 25, Name: KEY A
CSC 1051 Algorithms and Data Structures I Midterm Examination February 25, 2016 Name: KEY A Question Value Score 1 10 2 10 3 10 4 10 5 10 6 10 7 10 8 10 9 10 10 10 TOTAL 100 Please answer questions in
More informationTask #1 The if Statement, Comparing Strings, and Flags
Chapter 3 Lab Selection Control Structures Lab Objectives Be able to construct boolean expressions to evaluate a given condition Be able to compare Strings Be able to use a flag Be able to construct if
More informationArrays. Eng. Mohammed Abdualal
Islamic University of Gaza Faculty of Engineering Computer Engineering Department Computer Programming Lab (ECOM 2114) Created by Eng: Mohammed Alokshiya Modified by Eng: Mohammed Abdualal Lab 9 Arrays
More informationCondi(onals and Loops
Condi(onals and Loops 1 Review Primi(ve Data Types & Variables int, long float, double boolean char String Mathema(cal operators: + - * / % Comparison: < > = == 2 A Founda(on for Programming any program
More informationUniversity 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 informationChapter 5 Lab Methods
Chapter 5 Lab Methods Lab Objectives Be able to write methods Be able to call methods Be able to write javadoc comments Be able to create HTML documentation for our Java class using javadoc Introduction
More informationChapter 3 Lab Decision Structures
Chapter 3 Lab Decision Structures Lab Objectives Be able to construct boolean expressions to evaluate a given condition Be able to compare String objects Be able to use a flag Be able to construct if and
More informationMid Term Exam 1. Programming I (CPCS 202) Instructor: M. G. Abbas Malik Date: Sunday November 3, 2013 Total Marks: 50 Obtained Marks:
Mid Term Exam 1 Programming I (CPCS 202) Instructor: M. G. Abbas Malik Date: Sunday November 3, 2013 Student Name: Total Marks: 50 Obtained Marks: Instructions: Do not open this exam booklet until you
More informationMIDTERM REVIEW. midterminformation.htm
MIDTERM REVIEW http://pages.cpsc.ucalgary.ca/~tamj/233/exams/ midterminformation.htm 1 REMINDER Midterm Time: 7:00pm - 8:15pm on Friday, Mar 1, 2013 Location: ST 148 Cover everything up to the last lecture
More informationFaculty of Science COMP-202B - Introduction to Computing I (Winter 2009) Midterm Examination
First Name: Last Name: McGill ID: Section: Faculty of Science COMP-202B - Introduction to Computing I (Winter 2009) Midterm Examination Monday, March 9, 2009 Examiners: Mathieu Petitpas [Section 1] 18:30
More informationCIS Introduction to Computer Programming. 5 October 2012 Midterm
CIS 110-001 Introduction to Computer Programming 5 October 2012 Midterm Name: Recitation # (e.g. 201): Pennkey (e.g. bjbrown): My signature below certifies that I have complied with the University of Pennsylvania
More informationFaculty of Science COMP-202A - Introduction to Computing I (Fall 2008) Midterm Examination
First Name: Last Name: McGill ID: Section: Faculty of Science COMP-202A - Introduction to Computing I (Fall 2008) Midterm Examination Tuesday, November 4, 2008 Examiners: Mathieu Petitpas [Section 1] 18:30
More informationCSEN202: Introduction to Computer Science Spring Semester 2017 Midterm Exam
Page 0 German University in Cairo April 6, 2017 Media Engineering and Technology Faculty Prof. Dr. Slim Abdennadher CSEN202: Introduction to Computer Science Spring Semester 2017 Midterm Exam Bar Code
More informationYork University AK/ITEC OBJECT-BASED PROGRAMMING. Midterm Test Sample. Examiner: S.Y. Chen Duration: One Hour and Fifteen Minutes
York University AK/ITEC 1620 3.0 OBJECT-BASED PROGRAMMING Midterm Test Sample Examiner: S.Y. Chen Duration: One Hour and Fifteen Minutes This exam is closed textbook(s) and closed notes. Use of any electronic
More informationChapter 1 Lab Algorithms, Errors, and Testing
Chapter 1 Lab Algorithms, Errors, and Testing Lab Objectives Be able to write an algorithm Be able to compile a Java program Be able to execute a Java program using the Sun JDK or a Java IDE Be able to
More informationExam 1. Programming I (CPCS 202) Instructor: M. G. Abbas Malik. Total Marks: 45 Obtained Marks:
كلية الحاسبات وتقنية المعلوما Exam 1 Programming I (CPCS 202) Instructor: M. G. Abbas Malik Date: October 18, 2015 Student Name: Student ID: Total Marks: 45 Obtained Marks: Instructions: Do not open this
More informationQuestion: Total Points: Score:
CS 170 Exam 1 Section 000 Spring 2014 Name (print):. Instructions Keep your eyes on your own paper and do your best to prevent anyone else from seeing your work. Do NOT communicate with anyone other than
More informationJAVA PROGRAMMING LAB. ABSTRACT In this Lab you will learn to define and invoke void and return java methods
Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Computer Programming Lab (ECOM 2114) ABSTRACT In this Lab you will learn to define and invoke void and return java methods JAVA
More informationCSC 1051 Villanova University. CSC 1051 Data Structures and Algorithms I. Course website:
Repetition CSC 1051 Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website: www.csc.villanova.edu/~map/1051/ Some slides in this
More informationCOE 212 Engineering Programming. Welcome to Exam II Thursday April 21, Instructors: Dr. Salim Haddad Dr. Joe Tekli Dr. Wissam F.
1 COE 212 Engineering Programming Welcome to Exam II Thursday April 21, 2016 Instructors: Dr. Salim Haddad Dr. Joe Tekli Dr. Wissam F. Fawaz Name: Student ID: Instructions: 1. This exam is Closed Book.
More informationCS 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 informationFaculty of Science Midterm. COMP-202B - Introduction to Computing I (Winter 2008)
Student Name: Student Number: Section: Faculty of Science Midterm COMP-202B - Introduction to Computing I (Winter 2008) Friday, March 7, 2008 Examiners: Prof. Jörg Kienzle 18:15 20:15 Mathieu Petitpas
More informationSection 003 Fall CS 170 Exam 1. Name (print): Instructions:
CS 170 Exam 1 Section 003 Fall 2012 Name (print): Instructions: Keep your eyes on your own paper and do your best to prevent anyone else from seeing your work. Do NOT communicate with anyone other than
More informationQuestion: Total Points: Score:
CS 170 Exam 1 Section 001 Fall 2014 Name (print): Instructions: Keep your eyes on your own paper and do your best to prevent anyone else from seeing your work. Do NOT communicate with anyone other than
More informationInterpreted vs Compiled. Java Compile. Classes, Objects, and Methods. Hello World 10/6/2016. Python Interpreted. Java Compiled
Interpreted vs Compiled Python 1 Java Interpreted Easy to run and test Quicker prototyping Program runs slower Compiled Execution time faster Virtual Machine compiled code portable Java Compile > javac
More informationCOMP-202 Unit 4: Programming With Iterations. CONTENTS: The while and for statements
COMP-202 Unit 4: Programming With Iterations CONTENTS: The while and for statements Introduction (1) Suppose we want to write a program to be used in cash registers in stores to compute the amount of money
More informationA+ Computer Science -
import java.util.scanner; or just import java.util.*; reference variable Scanner keyboard = new Scanner(System.in); object instantiation Scanner frequently used methods Name nextint() nextdouble() nextfloat()
More informationRyerson University Vers HAL6891A-05 School of Computer Science CPS109 Midterm Test Fall 05 page 1 of 6
CPS109 Midterm Test Fall 05 page 1 of 6 Last Name First Name Student Number Circle Your Instructor Your last name here Your first name here Your student number here Ferworn Harley Instructions: (a) There
More informationCIS 110 Introduction to Computer Programming. February 29, 2012 Midterm
CIS 110 Introduction to Computer Programming February 29, 2012 Midterm Name: Recitation # (e.g. 201): Pennkey (e.g. bjbrown): My signature below certifies that I have complied with the University of Pennsylvania
More information(A) 99 ** (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution
Ch 5 Arrays Multiple Choice Test 01. An array is a ** (A) data structure with one, or more, elements of the same type. (B) data structure with LIFO access. (C) data structure, which allows transfer between
More informationCSC 1051 Data Structures and Algorithms I
Repetition CSC 1051 Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website: www.csc.villanova.edu/~map/1051/ Some slides in this
More information1 Short Answer (10 Points Each)
1 Short Answer (10 Points Each) 1. Write a for loop that will calculate a factorial. Assume that the value n has been input by the user and have the loop create n! and store it in the variable fact. Recall
More informationFollowing is the general form of a typical decision making structure found in most of the programming languages:
Decision Making Decision making structures have one or more conditions to be evaluated or tested by the program, along with a statement or statements that are to be executed if the condition is determined
More informationCIS 110 Introduction to Computer Programming Summer 2016 Midterm. Recitation # (e.g., 201):
CIS 110 Introduction to Computer Programming Summer 2016 Midterm Name: Recitation # (e.g., 201): Pennkey (e.g., paulmcb): My signature below certifies that I have complied with the University of Pennsylvania
More informationCSC Algorithms and Data Structures I. Midterm Examination February 25, Name:
CSC 1051-001 Algorithms and Data Structures I Midterm Examination February 25, 2016 Name: Question Value Score 1 10 2 10 3 10 4 10 5 10 6 10 7 10 8 10 9 10 10 10 TOTAL 100 Please answer questions in the
More informationCIS 110 Fall 2015 Introduction to Computer Programming 7 Oct 2015 Makeup Midterm Exam
CIS 110 Fall 2015 Introduction to Computer Programming 7 Oct 2015 Makeup Midterm Exam Name: Recitation # (e.g., 201): Pennkey (e.g., eeaton): My signature below certifies that I have complied with the
More informationChapter 2: Basic Elements of Java
Chapter 2: Basic Elements of Java TRUE/FALSE 1. The pair of characters // is used for single line comments. ANS: T PTS: 1 REF: 29 2. The == characters are a special symbol in Java. ANS: T PTS: 1 REF: 30
More informationNew York University Intro to Computer Science (CSCI-UA.101) Fall 2014 Midterm #1 Test G. Instructions:
NAME: New York University Intro to Computer Science (CSCI-UA.101) Fall 2014 Midterm #1 Test G Instructions: KEEP TEST BOOKLET CLOSED UNTIL YOU ARE INSTRUCTED TO BEGIN. Omit one page from this exam. To
More informationIntroduction to Computer Programming
Introduction to Computer Programming Lecture 2- Primitive Data and Stepwise Refinement Data Types Type - A category or set of data values. Constrains the operations that can be performed on data Many languages
More informationCOSC 123 Computer Creativity. Introduction to Java. Dr. Ramon Lawrence University of British Columbia Okanagan
COSC 123 Computer Creativity Introduction to Java Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Key Points 1) Introduce Java, a general-purpose programming language,
More informationAL GHURAIR UNIVERSITY College of Computing. Objectives: Examples: Text-printing program. CSC 209 JAVA I
AL GHURAIR UNIVERSITY College of Computing CSC 209 JAVA I week 2- Arithmetic and Decision Making: Equality and Relational Operators Objectives: To use arithmetic operators. The precedence of arithmetic
More informationPROGRAMMING 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 informationChapter 6 Lab Classes and Objects
Lab Objectives Chapter 6 Lab Classes and Objects Be able to declare a new class Be able to write a constructor Be able to write instance methods that return a value Be able to write instance methods that
More informationCIS 1068 Program Design and Abstraction Spring2016 Midterm Exam 1. Name SOLUTION
CIS 1068 Program Design and Abstraction Spring2016 Midterm Exam 1 Name SOLUTION Page Points Score 2 15 3 8 4 18 5 10 6 7 7 7 8 14 9 11 10 10 Total 100 1 P age 1. Program Traces (41 points, 50 minutes)
More informationCSE 142, Autumn 2007 Midterm Exam, Friday, November 2, 2007
CSE 142, Autumn 2007 Midterm Exam, Friday, November 2, 2007 Name: Section: Student ID #: TA: Rules: You have 50 minutes to complete this exam. You may receive a deduction if you keep working after the
More informationModule Contact: Dr Gavin Cawley, CMP Copyright of the University of East Anglia Version 1
UNIVERSITY OF EAST ANGLIA School of Computing Sciences Main Series UG Examination 2017-18 PROGRAMMING 1 CMP-4008Y Time allowed: 2 hours Answer FOUR questions. All questions carry equal weight. Notes are
More informationOver and Over Again GEEN163
Over and Over Again GEEN163 There is no harm in repeating a good thing. Plato Homework A programming assignment has been posted on Blackboard You have to convert three flowcharts into programs Upload the
More informationChapter 2. Elementary Programming
Chapter 2 Elementary Programming 1 Objectives To write Java programs to perform simple calculations To obtain input from the console using the Scanner class To use identifiers to name variables, constants,
More informationFinal Exam Practice. Partial credit will be awarded.
Please note that this problem set is intended for practice, and does not fully represent the entire scope covered in the final exam, neither the range of the types of problems that may be included in the
More informationComputer Programming, I. Laboratory Manual. Final Exam Solution
Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Final Exam Solution
More informationSequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade;
Control Statements Control Statements All programs could be written in terms of only one of three control structures: Sequence Structure Selection Structure Repetition Structure Sequence structure The
More informationCIS 110 Introduction to Computer Programming Fall 2017 Midterm. Recitation ROOM :
CIS 110 Introduction to Computer Programming Fall 2017 Midterm Name: Recitation ROOM : Pennkey (e.g., paulmcb): DO NOT WRITE YOUR ID# ABOVE, YOU WILL LOSE A POINT My signature below certifies that I have
More informationCS 101 Spring 2007 Midterm 2 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 informationCIS 110 Introduction to Computer Programming 8 October 2013 Midterm
CIS 110 Introduction to Computer Programming 8 October 2013 Midterm Name: Recitation # (e.g., 201): Pennkey (e.g., eeaton): My signature below certifies that I have complied with the University of Pennsylvania
More informationJava Classes: Random, Character A C S L E C T U R E 6
Java Classes: Random, Character A C S - 1903 L E C T U R E 6 Random An instance of the Random can be used to generate a stream of random values Typical process: 1. Create a Random object 2. Use the object
More informationENGR 2710U Midterm Exam UOIT SOLUTION SHEET
SOLUTION SHEET ENGR 2710U: Object Oriented Programming & Design Midterm Exam October 19, 2012, Duration: 80 Minutes (9 Pages, 14 questions, 100 Marks) Instructor: Dr. Kamran Sartipi Name: Student Number:
More information1.00 Introduction to Computers and Engineering Problem Solving Quiz 1 March 4, 2005
1.00 Introduction to Computers and Engineering Problem Solving Quiz 1 March 4, 2005 Name: E-mail Address: TA: Section: You have 80 minutes to complete this exam. For coding questions, you do not need to
More information