CS 102 / CS Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2010
|
|
- Victor Hampton
- 6 years ago
- Views:
Transcription
1 CS 102 / CS Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2010 What is your name?: There are two sections: I. True/False points; ( 30 questions, 2 points each) II. Multiple Choice points; ( 10 questions, 4 points each) points total This test is worth 10% of your final grade. Please fill in your answers on the bubble form. After the test you may keep these pages, but you must turn in your bubble form. This test is open book and open notes. You have 50 minutes. For the multiple choice problems, select the best answer for each one and select the appropriate letter on your answer sheet. Be careful - more than one answer may seem to be correct. Many questions are tricky. Some problems ask you to determine whether something is valid. Something is valid if it would not generate a compiler error and would execute without the program crashing. I. True/False: (2 points each) 1. In Java a class called Book should be stored in a file called Book.java 2. In Eclipse it is possible to step through a program one line at a time, however to do this you must enclose the code in the program inside of special comment markers. 3. If you want to use Eclipse to develop your Java programs, your computer must also have a Java Development Kit (JDK) installed. 4. Java programs can be compiled and run from the command line. 5. The main() method in a Java program must always call a mainloop() method, otherwise the program cannot run. 6. The name of a Java class must begin with a capital letter, otherwise the program will not run. 7. Variable names in Java by convention use mixed case, where the words are concatenated together and the first letter of each word is capitalized. 8. In a Java program a method that does not return anything can either have a return type of void or have no return type listed at all. 9. Java methods are private by default, which means they cannot be called from outside of that file. 10. The ASCII code value for A is decimal The ASCII code value for a is decimal The decimal value 23 in binary is Binary numbers use a left-most digit of 2 to represent negative numbers CS 102 / CS Intro. to Programming, Midterm Exam #1, page 1 of 8
2 14. Single line comments using // can be nested inside block comments using /* */ 15. A single System.out.println(...) statement can cause 3 output lines to be displayed. 16. Several System.out.print(...) statements can cause a single line of output to be displayed. 17. Each opening brace must have a corresponding closing brace 18. Variables that are of type boolean can be used interchangeably with variables of type int 19. Variables that are of type int can be stored into double variables, but double variables cannot be conversely stored into an int variable. 20. float and double variables are exactly the same. Those two variable declarations can be used interchangeably. 21. To end a Java program both the break or the exit statement may be used. 22. A do loop (also called a do-while loop) is the best choice for displaying a menu and handling the user response. 23. The section of code shown below would compile and run and give as output: 3 int sum = 0; for( int i=0; i<=3; i++) sum += i; System.out.println( sum); 24. The section of code shown below would compile and run: int sum = 0; for( ; ; ) ; System.out.println( sum); 25. Any code that can be written with a switch-case statement could also be written with multiple if-else statements. 26. The following statements in Java would be useful for helping check if the length of a String is 3 characters long. String name = "123"; if( name.length() = 3) System.out.println("Length is three."); 27. The output of the following lines of code is: Not Done End boolean Done = false; if (Done = false) System.out.println("Not"); if( Done = true) System.out.println("Done "); else System.out.println("Undecided "); System.out.println("End"); CS 102 / CS Intro. to Programming, Midterm Exam #1, page 2 of 8
3 28. The output of the following statements is: 10 Done int y = 4; int z = 6; System.out.print( "" + z + y); System.out.println(" Done"); 29. The following code prints the words: 1 Done char c= a ; switch (c) case a : System.out.print("1"); case b : System.out.print("2"); case c : System.out.print("3"); System.out.println(" Done"); 30. The following Java program could have all the spaces and new-line characters removed so that it was all on one line, and it would still compile, run, and give the same output. public class Sample public static void main(string[] args) int x = 5; int y = x+2; System.out.println("x+y:" + x + y); CS 102 / CS Intro. to Programming, Midterm Exam #1, page 3 of 8
4 II. Multiple Choice (4 points each) 31. What is the output of the code segment shown below: int i=3, j=5; int k = i+++j; System.out.println(i + " " + j + " " + k); a) b) c) d) Assume the code segment shown below, where method swapvalues2 is called. Output of this segment of code is: //... other code int x = 3, y = 7; System.out.println( change( x, y) ); //... other code public int change(int x, int y) int temp = y; y = x; x = temp; return x + y; a) 73 b) 37 c) 10 d) Does not compile CS 102 / CS Intro. to Programming, Midterm Exam #1, page 4 of 8
5 33. The output of the following code in Java is equivalent to: a) 3 * 9 b) c) 39 d) 93 int value = 3; int limit = 9; int result = 0; for(int x=0; x<limit; x++) result = result + value; System.out.println( result); 34. Consider the program segment given below. Its output is: int value = 0; for( int i=0; i<7; i++) value += i%2; System.out.println("Value is: " + value); a) Value is: 3 b) Value is: 7 c) Value is: 10 d) Does not compile 35. Consider the code given below. If its output is: what are the values for variables start, end, first and last? for( int i=start; i<=end; i++) for( int j=first; j<last; j++) System.out.printf("%5d",i*j); System.out.println(); a) int start=7, end=3, first=6, last=4; b) int start=4, end=7, first=3, last=6; c) int start=7, end=4, first=6, last=3; d) int start=3, end=7, first=4, last=6; CS 102 / CS Intro. to Programming, Midterm Exam #1, page 5 of 8
6 36. What is the output of the code given in the two columns below when an object of type Confuse is created and used to call method startup()? class Confuse private int x; private int y; public Confuse() x = 3; y = 6; private void first(int z) x = z; y++; private void second(int s, int t) setxy( (y+t), (x-s)); s = 1; t = 3; private void setxy( int s, int y) x = s; this.y = y; first( y); private void display() System.out.println(x + y); public void startup() first( y); second( y, x); display(); //end class Confuse a) 7 b) 6 c) 12 d) Consider method second shown at right, which itself uses method first. For positive numbers, how would you best describe the return value of method second? a) x + y b) x * x c) x * y d) x y public int first(int x, int y) int z=0; for (int i=0; i<y; i++) z += 1; return z; public int second(int x, int y) int z=1; for (int i=0; i<y; i++) z = first( y, x); return z; CS 102 / CS Intro. to Programming, Midterm Exam #1, page 6 of 8
7 38. What would be the output of the method call: method38( 1324); void method38( int number) int x = number; int count = 0; while ( x > 0) x = x / 10; count++; for( int i=0; i<count/2; i++) number = number / 10; System.out.println( number%10); a) 4 b) 1 c) 10 d) Compiler error 39. Consider ClassA given below, along with the driver class ClassADriver for it. class ClassA private int x; public ClassA() x = 1; public ClassA( int x) this.x = x+1; class ClassADriver public void doit() int value = 7; ClassA instance1 = new ClassA( value); instance1.x = value - 1; instance1.changevalue( 2); System.out.println("value is: " + instance1.x); //end ClassADriver public void changevalue(int val) x = x + val; //end ClassA When running method doit() in the ClassADriver class, the output will be: a) value is: 5 b) value is: 6 c) value is: 7 d) doesn t compile CS 102 / CS Intro. to Programming, Midterm Exam #1, page 7 of 8
8 40. Consider the method shown below. When passed a String, what does it return? public String method40( String theword) char c; String newword = ""; for( int i=0; i<theword.length(); i++) c = theword.charat( i); newword = ""; for( int j=0; j<theword.length(); j++) if( (j<=i)) newword = newword + theword.charat( j); else if( theword.charat( j) == c) newword = newword + theword.charat( j); theword = newword; return newword; a) Every other letter of the original String, starting with the first b) Every other letter of the original String, starting with the second c) The original String with all duplicate letters eliminated d) Only the letters from the original String that had duplicates CS 102 / CS Intro. to Programming, Midterm Exam #1, page 8 of 8
9 CS 102 / CS Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2010 What is your name?: There are two sections: I. True/False points; ( 30 questions, 2 points each) II. Multiple Choice points; ( 10 questions, 4 points each) points total This test is worth 10% of your final grade. Please fill in your answers on the bubble form. After the test you may keep these pages, but you must turn in your bubble form. This test is open book and open notes. You have 50 minutes. For the multiple choice problems, select the best answer for each one and select the appropriate letter on your answer sheet. Be careful - more than one answer may seem to be correct. Many questions are tricky. Some problems ask you to determine whether something is valid. Something is valid if it would not generate a compiler error and would execute without the program crashing. I. True/False: (2 points each) 1. In Java a class called Book should be stored in a file called Book.java 2. In Eclipse it is possible to step through a program one line at a time, however to do this you must enclose the code in the program inside of special comment markers. 3. If you want to use Eclipse to develop your Java programs, your computer must also have a Java Development Kit (JDK) installed. 4. Java programs can be compiled and run from the command line. 5. The main() method in a Java program must always call a mainloop() method, otherwise the program cannot run. 6. The name of a Java class must begin with a capital letter, otherwise the program will not run. 7. Variable names in Java by convention use mixed case, where the words are concatenated together and the first letter of each word is capitalized. 8. In a Java program a method that does not return anything can either have a return type of void or have no return type listed at all. 9. Java methods are private by default, which means they cannot be called from outside of that file. 10. The ASCII code value for A is decimal The ASCII code value for a is decimal The decimal value 23 in binary is Binary numbers use a left-most digit of 2 to represent negative numbers CS 102 / CS Intro. to Programming, Midterm Exam #1, page 1 of 8
10 14. Single line comments using // can be nested inside block comments using /* */ 15. A single System.out.println(...) statement can cause 3 output lines to be displayed. 16. Several System.out.print(...) statements can cause a single line of output to be displayed. 17. Each opening brace must have a corresponding closing brace 18. Variables that are of type boolean can be used interchangeably with variables of type int 19. Variables that are of type int can be stored into double variables, but double variables cannot be conversely stored into an int variable. 20. float and double variables are exactly the same. Those two variable declarations can be used interchangeably. 21. To end a Java program both the break or the exit statement may be used. 22. A do loop (also called a do-while loop) is the best choice for displaying a menu and handling the user response. 23. The section of code shown below would compile and run and give as output: 3 int sum = 0; for( int i=0; i<=3; i++) sum += i; System.out.println( sum); 24. The section of code shown below would compile and run: int sum = 0; for( ; ; ) ; System.out.println( sum); 25. Any code that can be written with a switch-case statement could also be written with multiple if-else statements. 26. The following statements in Java would be useful for helping check if the length of a String is 3 characters long. String name = "123"; if( name.length() = 3) System.out.println("Length is three."); 27. The output of the following lines of code is: Not Done End boolean Done = false; if (Done = false) System.out.println("Not"); if( Done = true) System.out.println("Done "); else System.out.println("Undecided "); System.out.println("End"); CS 102 / CS Intro. to Programming, Midterm Exam #1, page 2 of 8
11 28. The output of the following statements is: 10 Done int y = 4; int z = 6; System.out.print( "" + z + y); System.out.println(" Done"); 29. The following code prints the words: 1 Done char c= a ; switch (c) case a : System.out.print("1"); case b : System.out.print("2"); case c : System.out.print("3"); System.out.println(" Done"); 30. The following Java program could have all the spaces and new-line characters removed so that it was all on one line, and it would still compile, run, and give the same output. public class Sample public static void main(string[] args) int x = 5; int y = x+2; System.out.println("x+y:" + x + y); CS 102 / CS Intro. to Programming, Midterm Exam #1, page 3 of 8
12 II. Multiple Choice (4 points each) 31. What is the output of the code segment shown below: int i=3, j=5; int k = i+++j; System.out.println(i + " " + j + " " + k); a) b) c) d) Assume the code segment shown below, where method swapvalues2 is called. Output of this segment of code is: //... other code int x = 3, y = 7; System.out.println( change( x, y) ); //... other code public int change(int x, int y) int temp = y; y = x; x = temp; return x + y; a) 73 b) 37 c) 10 d) Does not compile CS 102 / CS Intro. to Programming, Midterm Exam #1, page 4 of 8
13 33. The output of the following code in Java is equivalent to: a) 3 * 9 b) c) 39 d) 93 int value = 3; int limit = 9; int result = 0; for(int x=0; x<limit; x++) result = result + value; System.out.println( result); 34. Consider the program segment given below. Its output is: int value = 0; for( int i=0; i<7; i++) value += i%2; System.out.println("Value is: " + value); a) Value is: 3 b) Value is: 7 c) Value is: 10 d) Does not compile 35. Consider the code given below. If its output is: what are the values for variables start, end, first and last? for( int i=start; i<=end; i++) for( int j=first; j<last; j++) System.out.printf("%5d",i*j); System.out.println(); a) int start=7, end=3, first=6, last=4; b) int start=4, end=7, first=3, last=6; c) int start=7, end=4, first=6, last=3; d) int start=3, end=7, first=4, last=6; CS 102 / CS Intro. to Programming, Midterm Exam #1, page 5 of 8
14 36. What is the output of the code given in the two columns below when an object of type Confuse is created and used to call method startup()? class Confuse private int x; private int y; public Confuse() x = 3; y = 6; private void first(int z) x = z; y++; private void second(int s, int t) setxy( (y+t), (x-s)); s = 1; t = 3; private void setxy( int s, int y) x = s; this.y = y; first( y); private void display() System.out.println(x + y); public void startup() first( y); second( y, x); display(); //end class Confuse a) 7 b) 6 c) 12 d) Consider method second shown at right, which itself uses method first. For positive numbers, how would you best describe the return value of method second? a) x + y b) x * x c) x * y d) x y public int first(int x, int y) int z=0; for (int i=0; i<y; i++) z += 1; return z; public int second(int x, int y) int z=1; for (int i=0; i<y; i++) z = first( y, x); return z; CS 102 / CS Intro. to Programming, Midterm Exam #1, page 6 of 8
15 38. What would be the output of the method call: method38( 1324); void method38( int number) int x = number; int count = 0; while ( x > 0) x = x / 10; count++; for( int i=0; i<count/2; i++) number = number / 10; System.out.println( number%10); a) 4 b) 1 c) 10 d) Compiler error 39. Consider ClassA given below, along with the driver class ClassADriver for it. class ClassA private int x; public ClassA() x = 1; public ClassA( int x) this.x = x+1; class ClassADriver public void doit() int value = 7; ClassA instance1 = new ClassA( value); instance1.x = value - 1; instance1.changevalue( 2); System.out.println("value is: " + instance1.x); //end ClassADriver public void changevalue(int val) x = x + val; //end ClassA When running method doit() in the ClassADriver class, the output will be: a) value is: 5 b) value is: 6 c) value is: 7 d) doesn t compile CS 102 / CS Intro. to Programming, Midterm Exam #1, page 7 of 8
16 40. Consider the method shown below. When passed a String, what does it return? public String method40( String theword) char c; String newword = ""; for( int i=0; i<theword.length(); i++) c = theword.charat( i); newword = ""; for( int j=0; j<theword.length(); j++) if( (j<=i)) newword = newword + theword.charat( j); else if( theword.charat( j) == c) newword = newword + theword.charat( j); theword = newword; return newword; a) Every other letter of the original String, starting with the first b) Every other letter of the original String, starting with the second c) The original String with all duplicate letters eliminated d) Only the letters from the original String that had duplicates CS 102 / CS Intro. to Programming, Midterm Exam #1, page 8 of 8
CS Introduction to Programming Midterm Exam #1 - Prof. Reed Spring 2010
CS 102 - Introduction to Programming Midterm Exam #1 - Prof. Reed Spring 2010 What is your name?: There are two sections: I. True/False..................... 60 points; ( 30 questions, 2 points each) II.
More informationCS 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 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 informationI. True/False: (2 points each)
CS 102 - Introduction to Programming Midterm Exam #2 - Prof. Reed Spring 2008 What is your name?: (2 points) There are three sections: I. True/False..............54 points; (27 questions, 2 points each)
More informationI. True/False: (2 points each) On your bubble form fill out a for true and b for false.
CS 102/107 - Introduction to Programming Midterm Exam #2 - Prof. Reed Fall 2010 What is your name?: There are three sections: I. True/False..............60 points; (30 questions, 2 points each) II. Multiple
More informationCS Introduction to Programming Midterm Exam #1 - Prof. Reed Spring What is your name?: (4 points for writing it on your answer sheet)
CS 102 - Introduction to Programming Midterm Exam #1 - Prof. Reed Spring 2008 What is your name?: (4 points for writing it on your answer sheet) There are two sections: I. True/False.....................
More informationI. True/False: (2 points each)
CS 102 - Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2004 What is your name?: (0 points) There are two sections: I. True/False..............52 points; ( 26 questions, 2 points each) II.
More informationCS Introduction to Programming Midterm Exam #1 - Prof. Reed Fall What is your name?: (3 points for writing it on your answer sheet)
CS 102 - Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2007 What is your name?: (3 points for writing it on your answer sheet) There are two sections: I. True/False.....................
More informationCS 102/107 - Introduction to Programming Midterm Exam #2 - Prof. Reed Spring 2011
CS 102/107 - Introduction to Programming Midterm Exam #2 - Prof. Reed Spring 2011 What is your name?: This test has the following sections: I. True/False... 60 points; (30 questions, 2 points each) II.
More informationI. True/False: (2 points each)
CS 102 - Introduction to Programming Midterm Exam #2 - Prof. Reed Fall 2008 What is your name?: There are three sections: I. True/False..............60 points; (30 questions, 2 points each) II. Multiple
More informationI. True/False: (2 points each)
CS 102 - Introduction to Programming Midterm Exam #2 - Prof. Reed Fall 2009 What is your name?: There are three sections: I. True/False..............50 points; (25 questions, 2 points each) II. Multiple
More informationCS Introduction to Programming Midterm Exam #2 - Prof. Reed Fall 2015
CS 141 - Introduction to Programming Midterm Exam #2 - Prof. Reed Fall 2015 You may take this test with you after the test, but you must turn in your answer sheet. This test has the following sections:
More informationCS Introduction to Programming Midterm Exam #1 - Prof. Reed Spring 03
CS 102 - Introduction to Programming Midterm Exam #1 - Prof. Reed Spring 03 What is your name?: (0 points) There are two sections: I. Short Questions.........40 points; (40 questions, 1 point each) II.
More informationCOE 212 Engineering Programming. Welcome to Exam I Tuesday November 11, 2014
1 COE 212 Engineering Programming Welcome to Exam I Tuesday November 11, 2014 Instructors: Dr. Bachir Habib Dr. George Sakr Dr. Joe Tekli Dr. Wissam F. Fawaz Name: Student ID: Instructions: 1. This exam
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 informationMidterm Exam CS 251, Intermediate Programming March 12, 2014
Midterm Exam CS 251, Intermediate Programming March 12, 2014 Name: NetID: Answer all questions in the space provided. Write clearly and legibly, you will not get credit for illegible or incomprehensible
More informationLecture 14 CSE11 Fall 2013 For loops, Do While, Break, Continue
Lecture 14 CSE11 Fall 2013 For loops, Do While, Break, Continue General Loops in Java Look at other loop constructions Very common while loop: do a loop a fixed number of times (MAX in the example) int
More informationCS Introduction to Programming Midterm Exam #2 - Prof. Reed Fall 2017
CS 141 - Introduction to Programming Midterm Exam #2 - Prof. Reed Fall 2017 You may take this test with you after the test, but you must turn in your answer sheet. This test has 25 multiple-choice questions,
More information3. Java - Language Constructs I
Educational Objectives 3. Java - Language Constructs I Names and Identifiers, Variables, Assignments, Constants, Datatypes, Operations, Evaluation of Expressions, Type Conversions You know the basic blocks
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 informationIn Java, data type boolean is used to represent Boolean data. Each boolean constant or variable can contain one of two values: true or false.
CS101, Mock Boolean Conditions, If-Then Boolean Expressions and Conditions The physical order of a program is the order in which the statements are listed. The logical order of a program is the order in
More informationCOE 212 Engineering Programming. Welcome to Exam II Monday May 13, 2013
1 COE 212 Engineering Programming Welcome to Exam II Monday May 13, 2013 Instructors: Dr. Randa Zakhour Dr. Maurice Khabbaz Dr. George Sakr Dr. Wissam F. Fawaz Name: Solution Key Student ID: Instructions:
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 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 informationOutline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail.
OOP in Java 1 Outline 1. Getting started, primitive data types and control structures 2. Classes and objects 3. Extending classes 4. Using some standard packages 5. OOP revisited Parts 1 to 3 introduce
More informationExpressions and Data Types CSC 121 Spring 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types
More informationDecisions in Java IF Statements
Boolean Values & Variables In order to make decisions, Java uses the concept of true and false, which are boolean values. Just as is the case with other primitive data types, we can create boolean variables
More informationKing 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 1 Semester: Fall 2017-18 Exercises Cover Sheet:
More informationCSE 201 JAVA PROGRAMMING I. Copyright 2016 by Smart Coding School
CSE 201 JAVA PROGRAMMING I Primitive Data Type Primitive Data Type 8-bit signed Two s complement Integer -128 ~ 127 Primitive Data Type 16-bit signed Two s complement Integer -32768 ~ 32767 Primitive Data
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 informationPrimitive Data, Variables, and Expressions; Simple Conditional Execution
Unit 2, Part 1 Primitive Data, Variables, and Expressions; Simple Conditional Execution Computer Science S-111 Harvard University David G. Sullivan, Ph.D. Overview of the Programming Process Analysis/Specification
More informationExpressions and Data Types CSC 121 Fall 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types and
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 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 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 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 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 informationUniversity of British Columbia CPSC 111, Intro to Computation Jan-Apr 2006 Tamara Munzner
University of British Columbia CPSC 111, Intro to Computation Jan-Apr 2006 Tamara Munzner Conditionals II Lecture 11, Thu Feb 9 2006 based on slides by Kurt Eiselt http://www.cs.ubc.ca/~tmm/courses/cpsc111-06-spr
More informationAccelerating Information Technology Innovation
Accelerating Information Technology Innovation http://aiti.mit.edu Cali, Colombia Summer 2012 Lección 03 Control Structures Agenda 1. Block Statements 2. Decision Statements 3. Loops 2 What are Control
More information4 Programming Fundamentals. Introduction to Programming 1 1
4 Programming Fundamentals Introduction to Programming 1 1 Objectives At the end of the lesson, the student should be able to: Identify the basic parts of a Java program Differentiate among Java literals,
More informationReview. Primitive Data Types & Variables. String Mathematical operators: + - * / % Comparison: < > <= >= == int, long float, double boolean char
Review Primitive Data Types & Variables int, long float, double boolean char String Mathematical operators: + - * / % Comparison: < > = == 1 1.3 Conditionals and Loops Introduction to Programming in
More informationCS 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 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 informationCSE 20. SAMPLE FINAL Version A Time: 180 minutes. The following precedence table is provided for your use:
CSE 20 SAMPLE FINAL Version A Time: 180 minutes Name The following precedence table is provided for your use: Precedence of Operators ( ) - (unary),!, ++, -- *, /, % +, - (binary) = = =,!= &&
More informationControl Structures in Java if-else and switch
Control Structures in Java if-else and switch Lecture 4 CGS 3416 Spring 2017 January 23, 2017 Lecture 4CGS 3416 Spring 2017 Selection January 23, 2017 1 / 26 Control Flow Control flow refers to the specification
More informationAP Computer Science A Summer Assignment 2017
AP Computer Science A Summer Assignment 2017 The objective of this summer assignment is to ensure that each student has the ability to compile and run code on a computer system at home. We will be doing
More informationGetting 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 informationCS 170 Exam 2. Version: A Fall Name (as in OPUS) (print): Instructions:
CS 170 Exam 2 Version: A Fall 2015 Name (as in OPUS) (print): Section: Seat Assignment: Instructions: Keep your eyes on your own paper and do your best to prevent anyone else from seeing your work. Do
More information1. Find the output of following java program. class MainClass { public static void main (String arg[])
1. Find the output of following java program. public static void main(string arg[]) int arr[][]=4,3,2,1; int i,j; for(i=1;i>-1;i--) for(j=1;j>-1;j--) System.out.print(arr[i][j]); 1234 The above java program
More informationJava 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 informationSchool of Computer Science CPS109 Course Notes 6 Alexander Ferworn Updated Fall 15. CPS109 Course Notes 6. Alexander Ferworn
CPS109 Course Notes 6 Alexander Ferworn Unrelated Facts Worth Remembering Use metaphors to understand issues and explain them to others. Look up what metaphor means. Table of Contents Contents 1 ITERATION...
More informationIT Introduction to Programming for I.T. Midterm Exam #1 - Prof. Reed Spring 2008
IT 101 - Introduction to Programming for I.T. Midterm Exam #1 - Prof. Reed Spring 2008 What is your name?: (0 points) There are two sections: I. True/False..................... 20 points; ( 10 questions,
More informationCS180. Exam 1 Review
CS180 Exam 1 Review What is the output to the following code? System.out.println("2 + 2 = " + (2 + 2)); System.out.println("2 + 2 = " + 2 + 2); What is the output to the following code? System.out.println(String.valueOf(15+20));
More informationMidterm Exam CS 251, Intermediate Programming October 8, 2014
Midterm Exam CS 251, Intermediate Programming October 8, 2014 Name: NetID: Answer all questions in the space provided. Write clearly and legibly, you will not get credit for illegible or incomprehensible
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 informationCS1004: Intro to CS in Java, Spring 2005
CS1004: Intro to CS in Java, Spring 2005 Lecture #16: Java conditionals/loops, cont d. Janak J Parekh janak@cs.columbia.edu Administrivia Midterms returned now Weird distribution Mean: 35.4 ± 8.4 What
More informationCSCI 135 Exam #1 Fundamentals of Computer Science I Fall 2014
CSCI 135 Exam #1 Fundamentals of Computer Science I Fall 2014 Name: This exam consists of 8 problems on the following 8 pages. You may use your two- sided hand- written 8 ½ x 11 note sheet during the exam.
More informationCOMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette
COMP 250: Java Programming I Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette Variables and types [Downey Ch 2] Variable: temporary storage location in memory.
More informationCS111: PROGRAMMING LANGUAGE II
CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1(c): Java Basics (II) Lecture Contents Java basics (part II) Conditions Loops Methods Conditions & Branching Conditional Statements A
More informationCS11 Java. Fall Lecture 1
CS11 Java Fall 2006-2007 Lecture 1 Welcome! 8 Lectures Slides posted on CS11 website http://www.cs.caltech.edu/courses/cs11 7-8 Lab Assignments Made available on Mondays Due one week later Monday, 12 noon
More informationData and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence
Data and Variables Data Types Expressions Operators Precedence String Concatenation Variables Declaration Assignment Shorthand operators Review class All code in a java file is written in a class public
More information5/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 informationMr. Monroe s Guide to Mastering Java Syntax
Mr. Monroe s Guide to Mastering Java Syntax Getting Started with Java 1. Download and install the official JDK (Java Development Kit). 2. Download an IDE (Integrated Development Environment), like BlueJ.
More informationCOMP-202 Unit 2: Java Basics. CONTENTS: Using Expressions and Variables Types Strings Methods
COMP-202 Unit 2: Java Basics CONTENTS: Using Expressions and Variables Types Strings Methods Assignment 1 Assignment 1 posted on WebCt and course website. It is due May 18th st at 23:30 Worth 6% Part programming,
More informationcis20.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 informationCS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University
CS 112 Introduction to Computing II Wayne Snyder Department Boston University Today: Java basics: Compilation vs Interpretation Program structure Statements Values Variables Types Operators and Expressions
More informationCS 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 information3. Convert 2E from hexadecimal to decimal. 4. Convert from binary to hexadecimal
APCS A Midterm Review You will have a copy of the one page Java Quick Reference sheet. This is the same reference that will be available to you when you take the AP Computer Science exam. 1. n bits can
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 informationMidterm I - CSE11 Fall 2013 CLOSED BOOK, CLOSED NOTES 50 minutes, 100 points Total.
Midterm I - CSE11 Fall 2013 CLOSED BOOK, CLOSED NOTES 50 minutes, 100 points Total. Name: ID: Problem 1) (8 points) For the following code segment, what are the values of i, j, k, and d, after the segment
More 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 informationSection 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 informationOct Decision Structures cont d
Oct. 29 - Decision Structures cont d Programming Style and the if Statement Even though an if statement usually spans more than one line, it is really one statement. For instance, the following if statements
More informationExpressions & Flow Control
Objectives Distinguish between instance and local variables 4 Expressions & Flow Control Describe how instance variables are initialized Identify and correct a Possible reference before assignment compiler
More informationCS 177 Spring 2010 Exam I
CS 177 Spring 2010 Exam I There are 25 multiple choice questions. Each one is worth 4 points. The total score for the exam is 100. Answer the multiple choice questions on the bubble sheet given. Fill in
More informationProgramming in the Small II: Control
Programming in the Small II: Control 188230 Advanced Computer Programming Asst. Prof. Dr. Kanda Runapongsa Saikaew (krunapon@kku.ac.th) Department of Computer Engineering Khon Kaen University Agenda Selection
More informationAP Programming - Chapter 6 Lecture
page 1 of 21 The while Statement, Types of Loops, Looping Subtasks, Nested Loops I. The while Statement Note: Loop - a control structure that causes a sequence of statement(s) to be executed repeatedly.
More informationIntro to Programming in Java Practice Midterm
600.107 Intro to Programming in Java Practice Midterm This test is closed book/notes. SHORT ANSWER SECTION [18 points total] 1) TRUE/FALSE - Please circle your choice: Tr for true, Fa for false. [1 point
More informationCONTENTS: Compilation Data and Expressions COMP 202. More on Chapter 2
CONTENTS: Compilation Data and Expressions COMP 202 More on Chapter 2 Programming Language Levels There are many programming language levels: machine language assembly language high-level language Java,
More informationRepe$$on CSC 121 Fall 2015 Howard Rosenthal
Repe$$on CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Learn the following three repetition methods, their similarities and differences, and how to avoid common errors when using them: while do-while
More informationclass objects instances Fields Constructors Methods static
Class Structure Classes A class describes a set of objects The objects are called instances of the class A class describes: Fields (instance variables)that hold the data for each object Constructors that
More informationFinal Exam. CSC 121 Fall 2015 TTH. Lecturer: Howard Rosenthal. Dec. 15, 2015
Final Exam. CSC 121 Fall 2015 TTH Lecturer: Howard Rosenthal Dec. 15, 2015 Your Name: Key The following questions (or parts of questions) in numbers 1-17 are all worth 2 points each. The programs have
More informationLecture 14. 'for' loops and Arrays
Lecture 14 'for' loops and Arrays For Loops for (initiating statement; conditional statement; next statement) // usually incremental body statement(s); The for statement provides a compact way to iterate
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 informationCOMP-202: Foundations of Programming. Lecture 2: Variables, and Data Types Sandeep Manjanna, Summer 2015
COMP-202: Foundations of Programming Lecture 2: Variables, and Data Types Sandeep Manjanna, Summer 2015 Announcements Midterm Exams on 4 th of June (12:35 14:35) Room allocation will be announced soon
More informationProgram Fundamentals
Program Fundamentals /* HelloWorld.java * The classic Hello, world! program */ class HelloWorld { public static void main (String[ ] args) { System.out.println( Hello, world! ); } } /* HelloWorld.java
More informationCS 101 Fall 2005 Midterm 2 Name: ID:
This exam is open text book but closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts (in particular, the final two questions are worth substantially more than any
More informationSAMPLE 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 informationLecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan
Lecture 08-1 Programming in C++ PART 1 By Assistant Professor Dr. Ali Kattan 1 The Conditional Operator The conditional operator is similar to the if..else statement but has a shorter format. This is useful
More informationConnecting with Computer Science, 2e. Chapter 15 Programming II
Connecting with Computer Science, 2e Chapter 15 Programming II Objectives In this chapter you will: Gain an understanding of the basics of high-level programming languages, using Java and C++ as examples
More informationCourse 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 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 informationGive one example where you might wish to use a three dimensional array
CS 110: INTRODUCTION TO COMPUTER SCIENCE SAMPLE TEST 3 TIME ALLOWED: 60 MINUTES Student s Name: MAXIMUM MARK 100 NOTE: Unless otherwise stated, the questions are with reference to the Java Programming
More informationCS212 Midterm. 1. Read the following code fragments and answer the questions.
CS1 Midterm 1. Read the following code fragments and answer the questions. (a) public void displayabsx(int x) { if (x > 0) { System.out.println(x); return; else { System.out.println(-x); return; System.out.println("Done");
More informationC212 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 informationObject-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 informationBirkbeck (University of London) Software and Programming 1 In-class Test Mar 2018
Birkbeck (University of London) Software and Programming 1 In-class Test 2.1 22 Mar 2018 Student Name Student Number Answer ALL Questions 1. What output is produced when the following Java program fragment
More informationEx: If you use a program to record sales, you will want to remember data:
Data Variables Programs need to remember values. Ex: If you use a program to record sales, you will want to remember data: A loaf of bread was sold to Sione Latu on 14/02/19 for T$1.00. Customer Name:
More informationPractice Midterm 1 Answer Key
CS 120 Software Design I Fall 2018 Practice Midterm 1 Answer Key University of Wisconsin - La Crosse Due Date: October 5 NAME: Do not turn the page until instructed to do so. This booklet contains 10 pages
More 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 information