loop++; System.out.println(loop);

Size: px
Start display at page:

Download "loop++; System.out.println(loop);"

Transcription

1 What value is printed for the loop variable when the code shown below runs? int loop = 0; while (loop <= 10) { loop++; System.out.println(loop); A. 0 to 9 B. 0 to 10 C. 1 to 10 D. 1 to 11 E. Will not compile! cs163/164: Peer 4 - Control Loops - Fall Semester 2016 Question - 1

2 What value is printed for the loop variable when the code shown below runs? int loop = 0; while (loop <= 10) { loop++; System.out.println(loop); A. 0 to 9 B. 0 to 10 C. 1 to 10 D. 1 to 11 E. Will not compile! cs163/164: Peer 4 - Control Loops - Fall Semester 2016 Question - 2

3 What value is printed for the loop variable when the code shown below runs? int loop =0; while (loop <= 10) { loop++; System.out.println(loop); A. 9 B. 10 C. 11 D. 12 E. Will not compile! cs163/164: Peer 4 - Control Loops - Fall Semester 2016 Question - 3

4 What value is printed for the loop variable when the code shown below runs? int loop =0; while (loop <= 10) { loop++; System.out.println(loop); A. 9 B. 10 C. 11 D. 12 E. Will not compile! cs163/164: Peer 4 - Control Loops - Fall Semester 2016 Question - 4

5 How many times will the body of the do while loop execute? byte loop = -1; do { loop++; while (loop < 0); A. 0 times B. 1 time C. 2 times D. 128 times E. Infinite loop! cs163/164: Peer 4 - Control Loops - Fall Semester 2016 Question - 5

6 How many times will the body of the do while loop execute? byte loop = -1; do { loop++; while (loop < 0); A. 0 times B. 1 time C. 2 times D. 128 times E. Infinite loop! cs163/164: Peer 4 - Control Loops - Fall Semester 2016 Question - 6

7 cs163/164: Peer 4 - Control Loops - Fall Semester 2016 How many times will the body of the do while loop execute? byte loop = 0; do { loop++; while (loop > 0); A. 0 times B. 1 time C. 2 times D. 128 times E. Infinite loop! Questi on - 7

8 cs163/164: Peer 4 - Control Loops - Fall Semester 2016 How many times will the body of the do while loop execute? byte loop = 0; do { loop++; while (loop > 0); A. 0 times B. 1 time C. 2 times D. 128 times E. Infinite loop! Questi on - 8

9 cs163/164: Peer 3 - Math/Characters/Strings - Fall Semester 2016 What will the code shown below print to the console? System.out.println( Character.isDigit( A ) + "," + Character.isLetter( z ) + "," + Character.isLowerCase( & ) + "," + Character.isLetter("5A%".charAt(1)); A. true,false,true,false B. false,true,false,true C. false,true,false,false D. false,true,true,true Questi on - 9

10 cs163/164: Peer 3 - Math/Characters/Strings - Fall Semester 2016 What will the code shown below print to the console? System.out.println( Character.isDigit( A ) + "," + Character.isLetter( z ) + "," + Character.isLowerCase( & ) + "," + Character.isLetter("5A%".charAt(1)); A. true,false,true,false B. false,true,false,true C. false,true,false,false D. false,true,true,true Questio n - 10

11 cs163/164: Peer 3 - Math/Characters/Strings - Fall Semester 2016 What are the values of the double and integer after the code shown below executes? String mystring = "1.234"; double mydouble = Double.parseDouble(myString); int myinteger = Integer.parseInt(myString); A , 0 B , 1 C , 2 D. Program gets an exception! Questio n - 11

12 cs163/164: Peer 3 - Math/Characters/Strings - Fall Semester 2016 What are the values of the double and integer after the code shown below executes? String mystring = "1.234"; double mydouble = Double.parseDouble(myString); int myinteger = Integer.parseInt(myString); A , 0 B , 1 C , 2 D. Program gets an exception! Questio n - 12

13 cs163/164: Peer 4 - Control Loops - Fall Semester 2016 How many lines does the nested loop shown below print? for (int row = 0; row < 10; row += 2) { for (int col = 0; col < 50; col += 10) { System.out.println(row + "," + col) ; A. 20 times B. 25 times C. 36 times D. 500 times E. Different each time it runs! Questio n - 13

14 cs163/164: Peer 4 - Control Loops - Fall Semester 2016 How many lines does the nested loop shown below print? for (int row = 0; row < 10; row += 2) { for (int col = 0; col < 50; col += 10) { System.out.println(row + "," + col) ; A. 20 times B. 25 times C. 36 times D. 500 times E. Different each time it runs! Questio n - 14

15 cs163/164: Peer 4 - Control Loops - Fall Semester 2016 Which of the following correctly prints the entire contents of the string? String s = "Programming is fun!"; A. for (int i=1; i< s.length(); i++) System.out.print(s.charAt(i)); B. for (int i=1; i<= s.length(); ++i) System.out.print(s.charAt(i)); C. for (int i=0; i<= s.length(); i++) System.out.print(s.charAt(i)); D. for (int i=0; i< s.length(); ++i) System.out.print(s.charAt(i)); Questio n - 15

16 cs163/164: Peer 4 - Control Loops - Fall Semester 2016 Which of the following correctly prints the entire contents of the string? String s = "Programming is fun!"; A. for (int i=1; i< s.length(); i++) System.out.print(s.charAt(i)); B. for (int i=1; i<= s.length(); ++i) System.out.print(s.charAt(i)); C. for (int i=0; i<= s.length(); i++) System.out.print(s.charAt(i)); D. for (int i=0; i< s.length(); ++i) System.out.print(s.charAt(i)); Questio n - 16

17 cs163/164: Peer 4 - Control Loops - Fall Semester 2016 What is the last thing printed by the for loop shown below? for (String s = "Hello"; s.length() <= 10; s += "!") { System.out.println(s); A. Hello B. Hello! C. Hello!!!!! D.!!!!! E. None of the above Questio n - 17

18 cs163/164: Peer 4 - Control Loops - Fall Semester 2016 What is the last thing printed by the for loop shown below? for (String s = "Hello"; s.length() <= 10; s += "!") { System.out.println(s); A. Hello B. Hello! C. Hello!!!!! D.!!!!! E. None of the above Questio n - 18

Peer Instruction 1. Elementary Programming

Peer Instruction 1. Elementary Programming Peer Instruction 1 Elementary Programming 0 Which of the following variable declarations will not compile? Please select the single correct answer. A. int i = 778899; B. double x = 5.43212345; C. char

More information

5) (4 points) What is the value of the boolean variable equals after the following statement?

5) (4 points) What is the value of the boolean variable equals after the following statement? For problems 1-5, give a short answer to the question. (15 points, ~8 minutes) 1) (4 points) Write four Java statements that declare and initialize the following variables: A) a long integer with the value

More information

CS 163/164 Exam 2 Review

CS 163/164 Exam 2 Review CS 163/164 Exam 2 Review Review from first exam What does this print? String s = marco polo ; System.out.println(s.substring(0,3)); mar Print the predefined double variable d with 9 decimal place precision

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

Manipulating One-dimensional Arrays

Manipulating One-dimensional Arrays Manipulating One-dimensional Arrays Mitsu Ogihara Department of Computer Science University of Miami 1 / 30 Table of Contents 1 For each 2 Exchanging Values 3 Reversing 2 / 30 For-each iteration For enumerating

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

Loops! Step- by- step. An Example while Loop. Flow of Control: Loops (Savitch, Chapter 4)

Loops! Step- by- step. An Example while Loop. Flow of Control: Loops (Savitch, Chapter 4) Loops! Flow of Control: Loops (Savitch, Chapter 4) TOPICS while Loops do while Loops for Loops break Statement continue Statement CS 160, Fall Semester 2014 2 An Example while Loop Step- by- step int count

More information

Carleton University Department of Systems and Computer Engineering SYSC Foundations of Imperative Programming - Winter 2012

Carleton University Department of Systems and Computer Engineering SYSC Foundations of Imperative Programming - Winter 2012 Carleton University Department of Systems and Computer Engineering SYSC 2006 - Foundations of Imperative Programming - Winter 2012 Lab 1 - Introduction to Pelles C Objective To become familiar with the

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

1B1a Arrays. Arrays. Indexing. Naming arrays. Why? Using indexing. 1B1a Lecture Slides. Copyright 2003, Graham Roberts 1

1B1a Arrays. Arrays. Indexing. Naming arrays. Why? Using indexing. 1B1a Lecture Slides. Copyright 2003, Graham Roberts 1 Ba Arrays Arrays A normal variable holds value: An array variable holds a collection of values: 4 Naming arrays An array has a single name, so the elements are numbered or indexed. 0 3 4 5 Numbering starts

More information

CS211 Spring 2005 Prelim 1 March 10, Solutions. Instructions

CS211 Spring 2005 Prelim 1 March 10, Solutions. Instructions CS211 Spring 2005 Prelim 1 March 10, 2005 Solutions Instructions Write your name and Cornell netid above. There are 6 questions on 9 numbered pages. Check now that you have all the pages. Write your answers

More information

Question: Total Points: Score:

Question: 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 information

Array. Prepared By - Rifat Shahriyar

Array. Prepared By - Rifat Shahriyar Java More Details Array 2 Arrays A group of variables containing values that all have the same type Arrays are fixed length entities In Java, arrays are objects, so they are considered reference types

More information

Name Section Number. CS210 Exam #1 *** TURN OFF ALL ELECTRONIC DEVICES *** Practice

Name Section Number. CS210 Exam #1 *** TURN OFF ALL ELECTRONIC DEVICES *** Practice Name Section Number CS210 Exam #1 *** TURN OFF ALL ELECTRONIC DEVICES *** Practice Sections 3 and 4 Bob Wilson OPEN BOOK / OPEN NOTES: Spend only about one minute per point on each question to complete

More information

Section 003 Fall CS 170 Exam 1. Name (print): Instructions:

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

CS 163/164 Exam 2 Review

CS 163/164 Exam 2 Review CS 163/164 Exam 2 Review Review from first exam What does this print? String s = marco polo ; System.out.println(s.substring(0,3)); mar Print the predefined double variable d with 9 decimal place precision

More information

CS 307 Midterm 1 Fall 2007

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

More information

Chapter 4 Loops. int x = 0; while ( x <= 3 ) { x++; } System.out.println( x );

Chapter 4 Loops. int x = 0; while ( x <= 3 ) { x++; } System.out.println( x ); Chapter 4 Loops Sections Pages Review Questions Programming Exercises 4.1 4.7, 4.9 4.10 104 117, 122 128 2 9, 11 13,15 16,18 19,21 2,4,6,8,10,12,14,18,20,24,26,28,30,38 Loops Loops are used to make a program

More information

CS 101 Exam 1 Spring 200 Id Name

CS 101 Exam 1 Spring 200  Id Name This exam is open text book and closed notes. Different questions have different points associated with them with later occurring questions having more worth than the beginning questions. Because your

More information

Chapter 4: Control structures. Repetition

Chapter 4: Control structures. Repetition Chapter 4: Control structures Repetition Loop Statements After reading and studying this Section, student should be able to Implement repetition control in a program using while statements. Implement repetition

More information

AP CS Fall Semester Final

AP CS Fall Semester Final Name: Class: Date: AP CS Fall Semester Final Multiple Choice Identify the choice that best completes the statement or answers the question. 1. What is printed by the following code? int k = 3; for (int

More information

Java: Classes. An instance of a class is an object based on the class. Creation of an instance from a class is called instantiation.

Java: Classes. An instance of a class is an object based on the class. Creation of an instance from a class is called instantiation. Java: Classes Introduction A class defines the abstract characteristics of a thing (object), including its attributes and what it can do. Every Java program is composed of at least one class. From a programming

More information

OBJECTIVE QUESTIONS: Choose the correct alternative:

OBJECTIVE QUESTIONS: Choose the correct alternative: OBJECTIVE QUESTIONS: Choose the correct alternative: 1. Function is data type a) Primary b) user defined c) derived d) none 2. The declaration of function is called a) function prototype b) function call

More information

Chapter 4: Control structures

Chapter 4: Control structures Chapter 4: Control structures Repetition Loop Statements After reading and studying this Section, student should be able to Implement repetition control in a program using while statements. Implement repetition

More information

CS4215 Programming Language Implementation

CS4215 Programming Language Implementation CS4215 Programming Language Implementation You have 45 minutes to complete the exam. Use a B2 pencil to fill up the provided MCQ form. Leave Section A blank. Fill up Sections B and C. After finishing,

More information

that initializes the person s name from the input string. Consider the following fragment of Java code (inside some main method):

that initializes the person s name from the input string. Consider the following fragment of Java code (inside some main method): EECS1022 Winter 2018 Programming for Mobile Computing Example Exam Solution Time Limit: 30 minutes Name: (Last, First) Student ID 1. Assume that a Person class is already defined, and it has an attribute

More information

Introduction to Computer Science Midterm 3 Fall, Points

Introduction to Computer Science Midterm 3 Fall, Points Introduction to Computer Science Fall, 2001 100 Points Notes 1. Tear off this sheet and use it to keep your answers covered at all times. 2. Turn the exam over and write your name next to the staple. Do

More information

Outline of Fortran 90 Topics

Outline of Fortran 90 Topics Outline of Fortran 90 Topics Overview of Computing Computer Organization Languages Problem Solving Data Fortran 90 Character Set Variables Basic Data Types Expressions Numeric Non-numeric Control Structures

More information

King Saud University College of Computer and Information Sciences Computer Science Department

King Saud University College of Computer and Information Sciences Computer Science Department King Saud University College of Computer and Information Sciences Computer Science Department Course Code: CSC 111 Course Title: Introduction to Programming Semester: Fall 2017-2018 Exercises Cover Sheet:

More information

NATIONAL UNIVERSITY OF SINGAPORE

NATIONAL UNIVERSITY OF SINGAPORE NATIONAL UNIVERSITY OF SINGAPORE SCHOOL OF COMPUTING TERM TEST #1 Semester 1 AY2006/2007 CS1101X/Y/Z PROGRAMMING METHODOLOGY 16 September 2006 Time Allowed: 60 Minutes INSTRUCTIONS 1. This question paper

More information

Following is the general form of a typical decision making structure found in most of the programming languages:

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

CS Exam 2 Study Guide and Practice Exam

CS Exam 2 Study Guide and Practice Exam CS 160 - Exam 2 Study Guide and Practice Exam March 28, 2016 Summary 1 Disclaimer 2 Loops 2.1 For loops................................................. 2.2 While loops................................................

More information

Java: Comment Text. Introduction. Concepts

Java: Comment Text. Introduction. Concepts Java: Comment Text Introduction Comment text is text included in source code that is ignored by the compiler and does not cause any machine-language object code to be generated. It is written into the

More information

Advanced if/else & Cumulative Sum

Advanced if/else & Cumulative Sum Advanced if/else & Cumulative Sum Subset of the Supplement Lesson slides from: Building Java Programs, Chapter 4 by Stuart Reges and Marty Stepp (http://www.buildingjavaprograms.com/ ) Questions to consider

More information

CS159. Nathan Sprague. September 11, 2015

CS159. Nathan Sprague. September 11, 2015 CS159 Nathan Sprague September 11, 2015 Review of Arrays Declaration: int[] numbers; String[] words; Review of Arrays Declaration: int[] numbers; String[] words; Instantiation: numbers = new int[4]; words

More information

Java. Programming: Chapter Objectives. Why Is Repetition Needed? Chapter 5: Control Structures II. Program Design Including Data Structures

Java. Programming: Chapter Objectives. Why Is Repetition Needed? Chapter 5: Control Structures II. Program Design Including Data Structures Chapter 5: Control Structures II Java Programming: Program Design Including Data Structures Chapter Objectives Learn about repetition (looping) control structures Explore how to construct and use count-controlled,

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

AMCAT Procedure functions and scope Sample Questions

AMCAT Procedure functions and scope Sample Questions AMCAT Procedure functions and scope Sample Questions Question 1 A function cannot be defined inside another function A. True B. False Explanation: A function cannot be defined inside the another function,

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

CS 106 Introduction to Computer Science I

CS 106 Introduction to Computer Science I CS 106 Introduction to Computer Science I 05 / 31 / 2017 Instructor: Michael Eckmann Today s Topics Questions / Comments? recap and some more details about variables, and if / else statements do lab work

More information

Declaring a 2D Array

Declaring a 2D Array Lecture 13 Declaring a 2D Array Model: type name[row_size ][ column_size] Example: int grades[10][20]; string students[10][20]; 2D Array data structure Say we have the following array: int grades[4][8];

More information

CSIS 10A PRACTICE FINAL EXAM Name Closed Book Closed Computer 3 Sheets of Notes Allowed

CSIS 10A PRACTICE FINAL EXAM Name Closed Book Closed Computer 3 Sheets of Notes Allowed CSIS 10A PRACTICE FINAL EXAM Name Closed Book Closed Computer 3 Sheets of Notes Allowed MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) What would

More information

Supplementary Test 1

Supplementary Test 1 Name: Please fill in your Student Number and Name. Student Number : Student Number: University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ 2009 Supplementary Test 1 Question

More information

Recursion. What is Recursion? Simple Example. Repeatedly Reduce the Problem Into Smaller Problems to Solve the Big Problem

Recursion. What is Recursion? Simple Example. Repeatedly Reduce the Problem Into Smaller Problems to Solve the Big Problem Recursion Repeatedly Reduce the Problem Into Smaller Problems to Solve the Big Problem What is Recursion? A problem is decomposed into smaller sub-problems, one or more of which are simpler versions of

More information

Fall 2017 CISC124 9/16/2017

Fall 2017 CISC124 9/16/2017 CISC124 Labs start this week in JEFF 155: Meet your TA. Check out the course web site, if you have not already done so. Watch lecture videos if you need to review anything we have already done. Problems

More information

Introduction to Java Programming

Introduction to Java Programming Boaz Kantor Introduction to Computer Science, Fall semester 2009-2010 IDC Herzliya Welcome, geeks! Introduction to Java Programming Plan for today: 1. Before we begin.. 2. What is Java? 3. How to program?

More information

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018 Object-oriented programming 1 and data-structures CS/ENGRD 2110 SUMMER 2018 Lecture 1: Types and Control Flow http://courses.cs.cornell.edu/cs2110/2018su Lecture 1 Outline 2 Languages Overview Imperative

More information

Pull Lecture Materials and Open PollEv. Poll Everywhere: pollev.com/comp110. Lecture 12. else-if and while loops. Once in a while

Pull Lecture Materials and Open PollEv. Poll Everywhere: pollev.com/comp110. Lecture 12. else-if and while loops. Once in a while Pull Lecture Materials and Open PollEv Poll Everywhere: pollev.com/comp110 Lecture 12 else-if and while loops Once in a while Fall 2016 if-then-else Statements General form of an if-then-else statement:

More information

CS 1331 Exam 1. Fall Failure to properly fill in the information on this page will result in a deduction of up to 5 points from your exam score.

CS 1331 Exam 1. Fall Failure to properly fill in the information on this page will result in a deduction of up to 5 points from your exam score. CS 1331 Exam 1 Fall 2016 Name (print clearly): GT account (gpburdell1, msmith3, etc): Section (e.g., B1): Signature: Failure to properly fill in the information on this page will result in a deduction

More information

1 Truth. 2 Conditional Statements. Expressions That Can Evaluate to Boolean Values. Williams College Lecture 4 Brent Heeringa, Bill Jannen

1 Truth. 2 Conditional Statements. Expressions That Can Evaluate to Boolean Values. Williams College Lecture 4 Brent Heeringa, Bill Jannen 1 Truth Last lecture we learned about the int, float, and string types. Another very important object type in Python is the boolean type. The two reserved keywords True and False are values with type boolean.

More information

Control Statements Loops

Control Statements Loops CS 117 Spring 2004 Nested if statements if-else statements can reside within other if-else statements nested if statements Control Statements Loops April 26, 2004 Example (pseudocode) Get interest rate

More information

Prelim 1. CS 2110, 13 March 2018, 7:30 PM Total Question Name Short answer

Prelim 1. CS 2110, 13 March 2018, 7:30 PM Total Question Name Short answer Prelim 1 CS 2110, 13 March 2018, 7:30 PM 1 2 3 4 5 6 Total Question Name Short answer Exception handling Recursion OO Loop invariants Max 1 30 11 14 30 14 100 Score Grader The exam is closed book and closed

More information

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. CSIS 10A PRACTICE FINAL EXAM SOLUTIONS Closed Book Closed Computer 3 Sheets of Notes Allowed MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) What

More information

AP CS Unit 7: Arrays Exercises

AP CS Unit 7: Arrays Exercises AP CS Unit 7: Arrays Exercises 1. What is displayed? int [] a = new int[ 3 ]; System.out.println(a.length ); 2. What is displayed? int [] sting = { 34, 23, 67, 89, 12 ; System.out.println( sting[ 1 ] );

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

CS 101 Spring 2007 Midterm 2 Name: ID:

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

Introduction to Java https://tinyurl.com/y7bvpa9z

Introduction to Java https://tinyurl.com/y7bvpa9z Introduction to Java https://tinyurl.com/y7bvpa9z Eric Newhall - Laurence Meyers Team 2849 Alumni Java Object-Oriented Compiled Garbage-Collected WORA - Write Once, Run Anywhere IDE Integrated Development

More information

CS 307 Midterm 1[corrected] Spring 2008

CS 307 Midterm 1[corrected] Spring 2008 Points off 1 2 3 4 5 Total off Net Score CS 307 Midterm 1[corrected] Spring 2008 Your Name Your UTEID Circle yours TA s name: Ruchica Mario Vishvas Instructions: 1. Please turn off or silence your cell

More information

1KOd17RMoURxjn2 CSE 20 DISCRETE MATH Fall

1KOd17RMoURxjn2 CSE 20 DISCRETE MATH Fall CSE 20 https://goo.gl/forms/1o 1KOd17RMoURxjn2 DISCRETE MATH Fall 2017 http://cseweb.ucsd.edu/classes/fa17/cse20-ab/ Today's learning goals Explain the steps in a proof by mathematical and/or structural

More information

Section 004 Spring CS 170 Exam 1. Name (print): Instructions:

Section 004 Spring CS 170 Exam 1. Name (print): Instructions: CS 170 Exam 1 Section 004 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 information

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University Lecture 2 COMP1406/1006 (the Java course) Fall 2013 M. Jason Hinek Carleton University today s agenda a quick look back (last Thursday) assignment 0 is posted and is due this Friday at 2pm Java compiling

More information

CS302: Self Check Quiz 2

CS302: Self Check Quiz 2 CS302: Self Check Quiz 2 name: Part I True or False For these questions, is the statement true or false? Assume the statements are about the Java programming language. 1.) The result of an expression with

More information

Chapter 5. Section 5.4 The Common String Library Functions. CS 50 Hathairat Rattanasook

Chapter 5. Section 5.4 The Common String Library Functions. CS 50 Hathairat Rattanasook Chapter 5 Section 5.4 The Common String Library Functions CS 50 Hathairat Rattanasook Library Functions We already discussed the library function fgets() Library functions are available: to find the length

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

Week 1: Hello World! Muhao Chen

Week 1: Hello World! Muhao Chen Week 1: Hello World! Muhao Chen 1 Muhao Chen Teaching Fellow Email address: muhaochen@ucla.edu Office Hours: Thursday 11:30 ~ 2:30 PM BH2432 Personal office BH3551 Homepage (where I post slides): http://yellowstone.cs.ucla.edu/~muhao/

More information

Slide 1 CS 170 Java Programming 1 The Switch Duration: 00:00:46 Advance mode: Auto

Slide 1 CS 170 Java Programming 1 The Switch Duration: 00:00:46 Advance mode: Auto CS 170 Java Programming 1 The Switch Slide 1 CS 170 Java Programming 1 The Switch Duration: 00:00:46 Menu-Style Code With ladder-style if-else else-if, you might sometimes find yourself writing menu-style

More information

CSEN 202 Introduction to Computer Programming

CSEN 202 Introduction to Computer Programming CSEN 202 Introduction to Computer Programming Lecture 4: Iterations Prof. Dr. Slim Abdennadher and Dr Mohammed Abdel Megeed Salem, slim.abdennadher@guc.edu.eg German University Cairo, Department of Media

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

CS201- Introduction to Programming Current Quizzes

CS201- Introduction to Programming Current Quizzes CS201- Introduction to Programming Current Quizzes Q.1 char name [] = Hello World ; In the above statement, a memory of characters will be allocated 13 11 12 (Ans) Q.2 A function is a block of statements

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

CS 1331 Exam 1 ANSWER KEY

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

More information

Computers, Variables and Types. Engineering 1D04, Teaching Session 2

Computers, Variables and Types. Engineering 1D04, Teaching Session 2 Computers, Variables and Types Engineering 1D04, Teaching Session 2 Typical Computer Copyright 2006 David Das, Ryan Lortie, Alan Wassyng 1 An Abstract View of Computers Copyright 2006 David Das, Ryan Lortie,

More information

CS 61B Data Structures and Programming Methodology. June David Sun

CS 61B Data Structures and Programming Methodology. June David Sun CS 61B Data Structures and Programming Methodology June 25 2008 David Sun Announcements Visit 387 Soda to arrange for after hours access to Soda Hall. Computer Science Undergraduate Association event:

More information

Hashing. 5/1/2006 Algorithm analysis and Design CS 007 BE CS 5th Semester 2

Hashing. 5/1/2006 Algorithm analysis and Design CS 007 BE CS 5th Semester 2 Hashing Hashing A hash function h maps keys of a given type to integers in a fixed interval [0,N-1]. The goal of a hash function is to uniformly disperse keys in the range [0,N-1] 5/1/2006 Algorithm analysis

More information

Interpreted vs Compiled. Java Compile. Classes, Objects, and Methods. Hello World 10/6/2016. Python Interpreted. Java Compiled

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

QUIZ: loops. Write a program that prints the integers from -7 to 15 (inclusive) using: for loop while loop do...while loop

QUIZ: loops. Write a program that prints the integers from -7 to 15 (inclusive) using: for loop while loop do...while loop QUIZ: loops Write a program that prints the integers from -7 to 15 (inclusive) using: for loop while loop do...while loop QUIZ: loops Write a program that prints the integers from -7 to 15 using: for

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

Announcements. Project 1 will be posted today on webpage and cvs. Due Tuesday

Announcements. Project 1 will be posted today on webpage and cvs. Due Tuesday Announcements Project 1 will be posted today on webpage and cvs Due Tuesday More Loops A H: either 0 or 1 Printing in base 2 Printing in base 2 A H: either 0 or 1 Mask Printing in base 2 A H: either 0

More information

Arrays in Java Multi-dimensional Arrays

Arrays in Java Multi-dimensional Arrays Suppose you are tasked with writing a program to help maintain seating records for a theatre company. The auditorium has 25 rows, each of which contains 30 seats. One utility you need to provide is tracking

More information

Dept. of CSE, IIT KGP

Dept. of CSE, IIT KGP Control Flow: Looping CS10001: Programming & Data Structures Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Types of Repeated Execution Loop: Group of

More information

Slide 1 Side Effects Duration: 00:00:53 Advance mode: Auto

Slide 1 Side Effects Duration: 00:00:53 Advance mode: Auto Side Effects The 5 numeric operators don't modify their operands Consider this example: int sum = num1 + num2; num1 and num2 are unchanged after this The variable sum is changed This change is called a

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

STRUCTURED DATA TYPE ARRAYS IN C++ ONE-DIMENSIONAL ARRAY TWO-DIMENSIONAL ARRAY

STRUCTURED DATA TYPE ARRAYS IN C++ ONE-DIMENSIONAL ARRAY TWO-DIMENSIONAL ARRAY STRUCTURED DATA TYPE ARRAYS IN C++ ONE-DIMENSIONAL ARRAY TWO-DIMENSIONAL ARRAY Objectives Declaration of 1-D and 2-D Arrays Initialization of arrays Inputting array elements Accessing array elements Manipulation

More information

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

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

More information

CS110: PROGRAMMING LANGUAGE I

CS110: PROGRAMMING LANGUAGE I CS110: PROGRAMMING LANGUAGE I Computer Science Department Lecture 4: Java Basics (II) A java Program 1-2 Class in file.java class keyword braces {, } delimit a class body main Method // indicates a comment.

More information

Algebra 1 Semester 2 Final Review

Algebra 1 Semester 2 Final Review Team Awesome 011 Name: Date: Period: Algebra 1 Semester Final Review 1. Given y mx b what does m represent? What does b represent?. What axis is generally used for x?. What axis is generally used for y?

More information

String Computation Program

String Computation Program String Computation Program Reference Manual Scott Pender scp2135@columbia.edu COMS4115 Fall 2012 10/31/2012 1 Lexical Conventions There are four kinds of tokens: identifiers, keywords, expression operators,

More information

Final Exam CS 152, Computer Programming Fundamentals December 9, 2016

Final Exam CS 152, Computer Programming Fundamentals December 9, 2016 Final Exam CS 152, Computer Programming Fundamentals December 9, 2016 Name: NetID: Answer all questions in the space provided. Write clearly and legibly, you will not get credit for illegible or incomprehensible

More information

CS Introduction to Computational and Data Science. Instructor: Renzhi Cao Computer Science Department Pacific Lutheran University Spring 2017

CS Introduction to Computational and Data Science. Instructor: Renzhi Cao Computer Science Department Pacific Lutheran University Spring 2017 CS 133 - Introduction to Computational and Data Science Instructor: Renzhi Cao Computer Science Department Pacific Lutheran University Spring 2017 Previous class We have learned the path and file system.

More information

Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. CMPSC11 Final (Study Guide) Fall 11 Prof Hartman Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) This is a collection of statements that performs

More information

L o o p s. for(initializing expression; control expression; step expression) { one or more statements }

L o o p s. for(initializing expression; control expression; step expression) { one or more statements } L o o p s Objective #1: Explain the importance of loops in programs. In order to write a non trivial computer program, you almost always need to use one or more loops. Loops allow your program to repeat

More information

Lesson 35..Two-Dimensional Arrays

Lesson 35..Two-Dimensional Arrays Lesson 35..Two-Dimensional Arrays 35-1 Consider the following array (3 rows, 2 columns) of numbers: 22 23 24 25 26 27 Let s declare our array as follows: int a[ ] [ ] = new int [3] [2]; Subscript convention:

More information

Java Control Statements

Java Control Statements Java Control Statements An introduction to the Java Programming Language Produced by: Eamonn de Leastar (edeleastar@wit.ie) Dr. Siobhan Drohan (sdrohan@wit.ie) Department of Computing and Mathematics http://www.wit.ie/

More information

Classes and Objects 3/28/2017. How can multiple methods within a Java class read and write the same variable?

Classes and Objects 3/28/2017. How can multiple methods within a Java class read and write the same variable? Peer Instruction 8 Classes and Objects How can multiple methods within a Java class read and write the same variable? A. Allow one method to reference a local variable of the other B. Declare a variable

More information

CS 100 Python commands, computing concepts, and algorithmic approaches for final Fall 2015

CS 100 Python commands, computing concepts, and algorithmic approaches for final Fall 2015 CS 100 Python commands, computing concepts, and algorithmic approaches for final Fall 2015 These pages will NOT BE INCLUDED IN THE MIDTERM. print - Displays a value in the command area - Examples: - print

More information

Final. Your Name CS Fall 2014 December 13, points total Your Instructor and Section

Final. Your Name CS Fall 2014 December 13, points total Your Instructor and Section Final Your Name CS 1063 - Fall 2014 December 13, 2014 100 points total Your Instructor and Section I. (10 points, 1 point each) Match each of the terms on the left by choosing the upper case letter of

More information

Looping. Arizona State University 1

Looping. Arizona State University 1 Looping CSE100 Principles of Programming with C++, Fall 2018 (based off Chapter 5 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University

More information

Object Oriented Programming 2013/14. Final Exam June 20, 2014

Object Oriented Programming 2013/14. Final Exam June 20, 2014 Object Oriented Programming 2013/14 Final Exam June 20, 2014 Directions (read carefully): CLEARLY print your name and ID on every page. The exam contains 8 pages divided into 4 parts. Make sure you have

More information

9/19/12. Why Study Discrete Math? What is discrete? Sets (Rosen, Chapter 2) can be described by discrete math TOPICS

9/19/12. Why Study Discrete Math? What is discrete? Sets (Rosen, Chapter 2) can be described by discrete math TOPICS What is discrete? Sets (Rosen, Chapter 2) TOPICS Discrete math Set Definition Set Operations Tuples Consisting of distinct or unconnected elements, not continuous (calculus) Helps us in Computer Science

More information

UNIVERSITY OF CONNECTICUT. ECE 3411 Microprocessor Application Lab: Fall Quiz II

UNIVERSITY OF CONNECTICUT. ECE 3411 Microprocessor Application Lab: Fall Quiz II Department of Electrical and Computing Engineering UNIVERSITY OF CONNECTICUT ECE 3411 Microprocessor Application Lab: Fall 2015 Quiz II There are 5 questions in this quiz. There are 9 pages in this quiz

More information