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



Similar documents
Introduction to Java

JDK 1.5 Updates for Introduction to Java Programming with SUN ONE Studio 4

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

Introduction to Java Applications Pearson Education, Inc. All rights reserved.

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

Install Java Development Kit (JDK) 1.8

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

J a v a Quiz (Unit 3, Test 0 Practice)

System.out.println("\nEnter Product Number 1-5 (0 to stop and view summary) :

Handout 3 cs180 - Programming Fundamentals Spring 15 Page 1 of 6. Handout 3. Strings and String Class. Input/Output with JOptionPane.

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

Sample CSE8A midterm Multiple Choice (circle one)

Statements and Control Flow

Example of a Java program

Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013

Chapter 1. Introduction to Computers, Programs, and Java

Part I. Multiple Choice Questions (2 points each):

Moving from CS 61A Scheme to CS 61B Java

java.util.scanner Here are some of the many features of Scanner objects. Some Features of java.util.scanner

Arrays. Introduction. Chapter 7

Third AP Edition. Object-Oriented Programming and Data Structures. Maria Litvin. Gary Litvin. Phillips Academy, Andover, Massachusetts

Java Programming Fundamentals

AP Computer Science Java Subset

Chapter 2: Elements of Java

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

Chapter 2 Introduction to Java programming

Chapter 1 Introduction to Computers, Programs, and Java

Informatica e Sistemi in Tempo Reale

Object Oriented Software Design

CS1020 Data Structures and Algorithms I Lecture Note #1. Introduction to Java

6.1. Example: A Tip Calculator 6-1

MIDTERM 1 REVIEW WRITING CODE POSSIBLE SOLUTION

Chapter 2 Elementary Programming

Basic Programming and PC Skills: Basic Programming and PC Skills:

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Programming and Data Structures with Java and JUnit. Rick Mercer

COSC Introduction to Computer Science I Section A, Summer Question Out of Mark A Total 16. B-1 7 B-2 4 B-3 4 B-4 4 B Total 19

Topic 11 Scanner object, conditional execution

CS 106 Introduction to Computer Science I

An Overview of Java. overview-1

Programming in Java Course Technology, a part of Cengage Learning.

Scanner. It takes input and splits it into a sequence of tokens. A token is a group of characters which form some unit.

Chulalongkorn University International School of Engineering Department of Computer Engineering Computer Programming Lab.

Chapter 3. Input and output. 3.1 The System class

LOOPS CHAPTER CHAPTER GOALS

Pemrograman Dasar. Basic Elements Of Java

Topics. Parts of a Java Program. Topics (2) CS 146. Introduction To Computers And Java Chapter Objectives To understand:

Scoping (Readings 7.1,7.4,7.6) Parameter passing methods (7.5) Building symbol tables (7.6)

WA2099 Introduction to Java using RAD 8.0 EVALUATION ONLY. Student Labs. Web Age Solutions Inc.

1) Which of the following is a constant, according to Java naming conventions? a. PI b. Test c. x d. radius

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Programmierpraktikum

Building Java Programs

Chapter 2 Basics of Scanning and Conventional Programming in Java

Introduction to Java. CS 3: Computer Programming in Java

Explain the relationship between a class and an object. Which is general and which is specific?

Java Crash Course Part I

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

CSE 1223: Introduction to Computer Programming in Java Chapter 7 File I/O

13 File Output and Input

Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007

Object Oriented Software Design

CompSci 125 Lecture 08. Chapter 5: Conditional Statements Chapter 4: return Statement

Homework/Program #5 Solutions

Java Application Developer Certificate Program Competencies

Arrays in Java. Working with Arrays

Chapter 1 Java Program Design and Development

Using Files as Input/Output in Java 5.0 Applications

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

CS106A, Stanford Handout #38. Strings and Chars

CS 106 Introduction to Computer Science I

CS170 Lab 11 Abstract Data Types & Objects

MS Access: Advanced Tables and Queries. Lesson Notes Author: Pamela Schmidt

JavaScript: Control Statements I

Building Java Programs

Java Interview Questions and Answers

Lecture 1 Introduction to Java

Computer Programming I

JAVA - METHODS. Method definition consists of a method header and a method body. The same is shown below:

Introduction to Java Lecture Notes. Ryan Dougherty

Debugging. Common Semantic Errors ESE112. Java Library. It is highly unlikely that you will write code that will work on the first go

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

Software Testing. Definition: Testing is a process of executing a program with data, with the sole intention of finding errors in the program.

Fundamentals of Java Programming

Unit 6. Loop statements

JavaScript: Introduction to Scripting Pearson Education, Inc. All rights reserved.

Keywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : unsigned void

Programming Fundamentals I CS 110, Central Washington University. November 2015

The programming language C. sws1 1

Classes and Objects in Java Constructors. In creating objects of the type Fraction, we have used statements similar to the following:

Visual Logic Instructions and Assignments

PROBLEM SOLVING SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON

AP Computer Science Java Mr. Clausen Program 9A, 9B

Introduction to Object-Oriented Programming

Variables, Constants, and Data Types

Sources: On the Web: Slides will be available on:

Programming Languages CIS 443

Transcription:

Exam Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) The JDK command to compile a class in the file Test.java is A) java Test.java B) java Test C) javac Test D) javac Test.java E) JAVAC Test.java 1) 2) Java was developed by. A) IBM B) Microsoft C) Sun Microsystems D) Oracle E) Cisco Systems 2) 3) Which of the following are the reserved words? (Choose all that apply.) A) class B) public C) void D) static 3) 4) The method displays a message dialog box. (Choose all that apply.) A) JOptionPane.showMessageDialog(null, ʺWelcome to Java!ʺ, ʺExample 1.2 Outputʺ, JOptionPane.INFORMATION_MESSAGE); B) JOptionPane.displayMessage(null, ʺWelcome to Java!ʺ, ʺExample 1.2 Outputʺ, JOptionPane.INFORMATION_MESSAGE); C) JOptionPane.showMessageDialog(null, ʺWelcome to Java!ʺ); D) JOptionPane.displayMessageDialog(null, ʺWelcome to Java!ʺ, ʺExample 1.2 Outputʺ, JOptionPane.INFORMATION_MESSAGE); E) JOptionPane.showMessage(null, ʺWelcome to Java!ʺ, ʺExample 1.2 Outputʺ, JOptionPane.INFORMATION_MESSAGE); 4) 5) is an operating system. A) Windows XP B) Ada C) C++ D) Visual Basic E) Java 5) 6) Every statement in Java ends with. A) a period (.) B) an asterisk (*) C) a semicolon (;) D) a comma (,) 6) 7) is interpreted. A) Pascal B) Ada C) C++ D) C E) Java 7) 1

8) Which of the following statements is correct to display Welcome to Java on the console? (Choose all that apply.) A) System.out.print(ʹWelcome to Javaʹ); B) System.out.println(ʹWelcome to Javaʹ); C) System.out.println(ʺWelcome to Javaʺ); D) System.println(ʹWelcome to Javaʹ); E) System.out.print(ʺWelcome to Javaʺ); 8) 9) To use JOptionPane in your program, you may import it using: (Choose all that apply.) A) import javax.*.joptionpane; B) import javax.swing.joptionpane; C) import javax.*; D) import javax.swing.*; 9) 10) is Architecture-Neutral. A) Ada B) Java C) Pascal D) C E) C++ 10) 11) The extension name of a Java source code file is A).exe B).class C).obj D).java 11) 12) A block is enclosed inside. A) parentheses B) braces C) quotes D) brackets 12) 13) The speed of the CPU is measured in. (Choose all that apply.) A) gigabytes B) gigahertz C) megabytes D) megahertz 13) 14) is an object-oriented programming language. (Choose all that apply.) A) Java B) Pascal C) Ada D) C++ E) C 14) 15) Math.pow(2, 3) returns. A) 9.0 B) 9 C) 8.0 D) 8 15) 16) The method parses a string s to an int value. A) integer.parseinteger(s); B) integer.parseint(s); C) Integer.parseInt(s); D) Integer.parseInteger(s); 16) 17) The expression ʺJava ʺ + 1 + 2 + 3 evaluates to. A) Java 123 B) Java123 C) java 123 D) Java6 E) Illegal expression 17) 18) Which of the following is the correct expression of character 4? A) 4 B) ʹ4ʹ C) ʹ\0004ʹ D) ʺ4ʺ 18) 19) What is the printout of System.out.println(ʹzʹ - ʹaʹ)? A) z B) a C) 25 D) 26 19) 2

20) Analyze the following code. 20) import javax.swing.*; public class ShowErrors { public static void main(string[ ] args) { int i; int j; String s = JOptionPane.showInputDialog(null, ʺEnter an integerʺ, ʺInputʺ, JOptionPane.QUESTION_MESSAGE); j = Integer.parseInt(s); i = (i + 4); A) The program cannot compile because i does not have an initial value when it is used in i = i + 4; B) The program cannot compile because j is not initialized. C) The program compiles but has a runtime error because i does not have an initial value when it is used in i = i + 4; D) The program compiles and runs fine. 21) Which of the following expression results in a value 1? A) 25 % 5 B) 15 % 4 C) 37 % 6 D) 2 % 1 21) 22) Which of the following assignment statements is illegal? (Choose all that apply.) A) int t = (int)false; B) float f = -34; C) short s = 10; D) int t = 4.5; E) int t = 23; 22) 23) What is the value of (double)(5/2)? A) 2.0 B) 3 C) 2.5 D) 2 E) 3.0 23) 24) -25 % 5 is. A) 1 B) 2 C) 3 D) 4 E) 0 24) 25) -24 % -5 is. A) 3 B) -3 C) 4 D) -4 E) 0 25) 26) -24 % 5 is. A) -1 B) -2 C) -3 D) -4 E) 0 26) 27) is the code with natural language mixed with Java code. A) A Java statement B) A flowchart diagram C) Pseudocode D) Java program 27) 3

28) To check whether a char variable ch is an uppercase letter, you write. A) (ʹAʹ <= ch <= ʹZʹ) B) (ch >= ʹAʹ && ch >= ʹZʹ) C) (ch >= ʹAʹ ch <= ʹZʹ) D) (ch >= ʹAʹ && ch <= ʹZʹ) 28) 29) The statement System.out.printf(ʺ%3.1fʺ, 1234.56) outputs. A) 1234.56 B) 123.4 C) 1234.5 D) 123.5 E) 1234.6 29) 30) The following code displays. 30) double temperature = 50; if (temperature >= 100) System.out.println(ʺtoo hotʺ); else if (temperature <= 40) System.out.println(ʺtoo coldʺ); else System.out.println(ʺjust rightʺ); A) just right B) too hot too cold just right C) too hot D) too cold 31) What is the printout of the following switch statement? 31) char ch = ʹbʹ; switch (ch) { case ʹaʹ: System.out.print(ch); case ʹbʹ: System.out.print(ch); case ʹcʹ: System.out.print(ch); case ʹdʹ: System.out.print(ch); A) abcd B) bb C) bbb D) bcd E) b 32) The order of the precedence (from high to low) of the operators +, *, &&,, & is: A) *, +, &&,, & B) &,, &&, *, + C) *, +, &, &&, D) *, +, &,, && E) &&,, &, *, + 32) 33) Which of the following are valid specifiers for the printf statement? (Choose all that apply.) A) %10b B) %6d C) %4c D) %10.2e E) %8.2d 33) 34) What is 1 + 1 + 1 + 1 + 1 == 5? A) true B) false C) There is no guarantee that 1 + 1 + 1 + 1 + 1 == 5 is true. 34) 4

35) Analyze the following program fragment: 35) int x; double d = 1.5; switch (d) { case 1.0: x = 1; case 1.5: x = 2; case 2.0: x = 3; A) The program has a compile error because the required default case is missing in the switch statement. B) The switch control variable cannot be double. C) The program has a compile error because the required break statement is missing in the switch statement. D) No errors. 36) Analyze the following code: 36) int i = 3434; double d = 3434; System.out.printf(ʺ%5.1f %5.1fʺ, i, d); A) The code compiles and runs fine to display 3434 3434.0. B) The code compiles and runs fine to display 3434.0 3434.0. C) i is an integer, but the format specifier %5.1f specifies a format for double value. The code has an error. 37) How many times will the following code print ʺWelcome to Javaʺ? 37) int count = 0; do { System.out.println(ʺWelcome to Javaʺ); count++; while (count < 10); A) 8 B) 9 C) 0 D) 11 E) 10 5

38) Suppose the input for number is 9. What is the output from running the following program? 38) import java.util.scanner; public class Test { public static void main(string[ ] args) { Scanner input = new Scanner(System.in); System.out.print(ʺEnter an integer: ʺ); int number = input.nextint(); int i; boolean isprime = true; for (i = 2; i < number && isprime; i++) { if (number % i == 0) { isprime = false; System.out.println(ʺi is ʺ + i); if (isprime) System.out.println(number + ʺ is primeʺ); else System.out.println(number + ʺ is not primeʺ); A) i is 3 followed by 9 is not prime B) i is 4 followed by 9 is prime C) i is 4 followed by 9 is not prime D) i is 3 followed by 9 is prime 39) Will the following program terminate? 39) int balance = 10; while (true) { if (balance < 9) continue; balance = balance - 9; A) Yes B) No 40) How many times will the following code print ʺWelcome to Javaʺ? 40) int count = 0; do { System.out.println(ʺWelcome to Javaʺ); while (count++ < 10); A) 0 B) 9 C) 8 D) 10 E) 11 6

41) Analyze the following statement: 41) double sum = 0; for (double d = 0; d<10;) { d += 0.1; sum += sum + d; A) The program has a compile error because the control variable in the for loop cannot be of the double type. B) The program has a compile error because the adjustment is missing in the for loop. C) The program compiles and runs fine. D) The program runs in an infinite loop because d<10 would always be true. 42) Analyze the following code. (Choose all that apply.) 42) int count = 0; while (count < 100) { // Point A System.out.println(ʺWelcome to Java!ʺ); count++; // Point B // Point C A) count < 100 is always true at Point C B) count < 100 is always true at Point B C) count < 100 is always true at Point A D) count < 100 is always false at Point B E) count < 100 is always false at Point C 43) Is the following loop correct? 43) for (; ; ); A) Yes B) No 44) What is the number of iterations in the following loop: 44) for (int i = 1; i < n; i++) { // iteration A) n + 1 B) n - 1 C) 2*n D) n 7

45) What is i after the following for loop? 45) int y = 0; for (int i = 0; i<10; ++i) { y += i; A) 11 B) 10 C) 9 D) undefined 46) Given the following method 46) static void nprint(string message, int n) { while (n > 0) { System.out.print(message); n--; What is the printout of the call nprint(ʹaʹ, 4)? A) aaaaa B) invalid call C) aaa D) aaaa 47) Does the return statement in the following method cause compile errors? 47) public static void main(string[ ] args) { int max = 0; if (max!= 0) System.out.println(max); else return; A) Yes B) No 48) All Java applications must have a method. A) public static Main(String args[ ]) B) public static Main(String[ ] args) C) public void main(string[ ] args) D) public static void main(string[ ] args) E) public static main(string[ ] args) 48) 49) is to implement one method in the structure chart at a time from the top to the bottom. A) Bottom-up and top-down approach B) Stepwise refinement C) Top-down approach D) Bottom-up approach 49) 50) When you invoke a method with a parameter, the value of the argument is passed to the parameter. This is referred to as. A) pass by value B) method invocation C) pass by name D) pass by reference 50) 8

51) Does the method call in the following method cause compile errors? 51) public static void main(string[ ] args) { Math.pow(2, 4); A) Yes B) No 52) Given the following method 52) static void nprint(string message, int n) { while (n > 0) { System.out.print(message); n--; What is k after invoking nprint(ʺa messageʺ, k)? int k = 2; nprint(ʺa messageʺ, k); A) 3 B) 1 C) 0 D) 2 53) The selectionsort method is defined in this section. What is list1 after executing the following statements? 53) double[ ] list1 = {3.1, 3.1, 2.5, 6.4; selectionsort(list1); A) list1 is 6.4, 3.1, 3.1, 2.5 B) list1 is 2.5 3.1, 3.1, 6.4 C) list1 is 3.1, 2.5, 3.1, 6.4 D) list1 is 3.1, 3.1, 2.5, 6.4 54) If you declare an array double[ ] list = {3.4, 2.0, 3.5, 5.5, the highest index in array list is. A) 0 B) 3 C) 1 D) 4 E) 2 54) 55) What is the correct term for numbers[99]? A) array B) index C) index variable D) indexed variable E) array variable 55) 56) Suppose a method p has the following heading: 56) public static int[ ] p() What return statement may be used in p()? A) return int[ ]{1, 2, 3; B) return 1; C) return {1, 2, 3; D) return new int[ ]{1, 2, 3; 9

57) Which of the following statements are correct to invoke the printmax method in Listing 6.5 in the textbook? (Choose all that apply.) A) printmax(1, 2, 2, 1, 4); B) printmax(1.0, 2.0, 2.0, 1.0, 4.0); C) printmax(new double[ ]{1, 2, 3); D) printmax(new int[ ]{1, 2, 3); 57) 58) The selectionsort method is defined in this section. Assume list is {3.1, 3.1, 2.5, 6.4, 2.1, what is the content of list after the first iteration of the outer loop in the method? A) 2.1, 2.5, 3.1, 3.1, 6.4 B) 3.1, 3.1, 2.5, 6.4, 2.1 C) 3.1, 3.1, 2.5, 2.1, 6.4 D) 2.5, 3.1, 3.1, 6.4, 2.1 58) 59) Analyze the following code: 59) public class Test { public static void main(string[ ] args) { boolean[ ][ ] x = new boolean[3][ ]; x[0] = new boolean[1]; x[1] = new boolean[2]; x[2] = new boolean[3]; System.out.println(ʺx[2][2] is ʺ + x[2][2]); A) The program runs and displays x[2][2] is false. B) The program runs and displays x[2][2] is true. C) The program runs and displays x[2][2] is null. D) The program has a runtime error because x[2][2] is null. E) The program has a compile error because new boolean[3][ ] is wrong. 60) Assume double[ ][ ] x = new double[4][5], what are x.length and x[2].length? A) 5 and 5 B) 4 and 5 C) 5 and 4 D) 4 and 4 60) 61) Assume double[ ][ ][ ] x = new double[4][5][6], what are x.length, x[2].length, and x[0][0].length? A) 4, 5, and 4 B) 4, 5, and 6 C) 5, 5, and 5 D) 6, 5, and 4 61) 62) Which of the following statements are correct? (Choose all that apply.) A) char[ ][ ][ ] chararray = new char[2][2][ ]; B) char[2][2][ ] chararray = {ʹaʹ, ʹbʹ; C) char[ ][ ][ ] chararray = {{{ʹaʹ, ʹbʹ, {ʹcʹ, ʹdʹ, {ʹeʹ, ʹfʹ; D) char[ ][ ][ ] chararray = {{ʹaʹ, ʹbʹ, {ʹcʹ, ʹdʹ, {ʹeʹ, ʹfʹ; 62) 63) Suppose a method p has the following heading: 63) public static int[ ][ ] p() What return statement may be used in p()? A) return 1; B) return new int[ ]{1, 2, 3; C) return {1, 2, 3; D) return int[ ]{1, 2, 3; E) return new int[ ][ ]{{1, 2, 3, {2, 4, 5; 10

64) Which of the following statements are correct? A) char[ ][ ] chararray = {{ʹaʹ, ʹbʹ, {ʹcʹ, ʹdʹ; B) char[2][2] chararray = {{ʹaʹ, ʹbʹ, {ʹcʹ, ʹdʹ; C) char[2][ ] chararray = {{ʹaʹ, ʹbʹ, {ʹcʹ, ʹdʹ; D) char[ ][ ] chararray = {ʹaʹ, ʹbʹ; 64) 65) is the brain of a computer. A) Memory B) Disk C) Hardware D) CPU 65) 66) provides an integrated development environment (IDE) for rapidly developing Java programs. Editing, compiling, building, debugging, and online help are integrated in one graphical user interface. A) Java IDE B) Java JDK C) Java API D) Java language specification 66) 67) Which of the following statements is correct? A) Every class must end with a semicolon. B) Every statement in a program must end with a semicolon. C) Every method must end with a semicolon. D) Every comment line must end with a semicolon. E) Every line in a program must end with a semicolon. 67) 68) consists of a set of separate programs for developing and testing Java programs, each of which is invoked from a command line. A) Java language specification B) Java IDE C) Java API D) Java JDK 68) 69) Why do computers use zeros and ones? A) because binary numbers are simplest. B) because binary numbers are the bases upon which all other number systems are built. C) because combinations of zeros and ones can represent any numbers and characters. D) because digital devices have two stable states and it is natural to use one state for 0 and the other for 1. 69) 70) Which of the following is a constant, according to Java naming conventions? (Choose all that apply.) A) read B) MAX_VALUE C) Test D) COUNT E) ReadInt 70) 71) What is y displayed in the following code? 71) public class Test { public static void main(string[ ] args) { int x = 1; int y = x++ + x; System.out.println(ʺy is ʺ + y); A) y is 2. B) y is 1. C) y is 4. D) y is 3. 11

72) The following code fragment reads in two numbers: (Choose all that apply.) 72) Scanner input = new Scanner(System.in); int i = input.nextint(); double d = input.nextdouble(); What are the correct ways to enter these two numbers? A) Enter a numeric value with a decimal point, a space, an integer, and then the Enter key. B) Enter an integer, a space, a double value, and then the Enter key. C) Enter an integer, an Enter key, a double value, and then the Enter key. D) Enter an integer, two spaces, a double value, and then the Enter key. 73) The Unicode of ʹaʹ is 97. What is the Unicode for ʹcʹ? A) 99 B) 97 C) 98 D) 96 73) 74) What is y after the following switch statement is executed? 74) x = 3; switch (x + 3) { case 6: y = 0; case 7: y = 1; default: y += 1; A) 3 B) 1 C) 2 D) 4 75) What is 1.0 + 1.0 + 1.0 + 1.0 + 1.0 == 5.0? A) true B) false C) There is no guarantee that 1.0 + 1.0 + 1.0 + 1.0 + 1.0 == 5.0 is true. 75) 76) The statement System.out.printf(ʺ%3.1eʺ, 1234.56) outputs. A) 0.1e+04 B) 1.23+03 C) 0.123456e+04 D) 1.2e+03 E) 0.123e+04 76) 77) What is the output for y? 77) int y = 0; for (int i = 0; i<10; ++i) { y += i; System.out.println(y); A) 45 B) 11 C) 10 D) 12 E) 13 12

78) How many times will the following code print ʺWelcome to Javaʺ? 78) int count = 0; while (count < 10) { System.out.println(ʺWelcome to Javaʺ); count++; A) 11 B) 9 C) 8 D) 10 E) 0 79) Analyze the following code: (Choose all that apply.) 79) public class Test { public static void main (String args[ ]) { int i = 0; for (i = 0; i < 10; i++); System.out.println(i + 4); A) The program compiles despite the semicolon (;) on the for loop line, and displays 14. B) The program has a compile error because of the semicolon (;) on the for loop line. C) The program compiles despite the semicolon (;) on the for loop line, and displays 4. D) The for loop in this program is same as for (i = 0; i < 10; i++) { ; System.out.println(i + 4); 80) A variable defined inside a method is referred to as. A) a local variable B) a global variable C) a method variable D) a block variable 80) 81) What is Math.ceil(3.6)? A) 4.0 B) 5.0 C) 3.0 D) 3 81) 82) The signature of a method consists of. A) return type, method name, and parameter list B) parameter list C) method name D) method name and parameter list 82) 83) The reverse method is defined in this section. What is list1 after executing the following statements? 83) int[ ] list1 = {1, 2, 3, 4, 5, 6; int[ ] list2 = reverse(list1); A) list1 is 1 2 3 4 5 6 B) list1 is 0 0 0 0 0 0 C) list1 is 6 5 4 3 2 1 D) list1 is 6 6 6 6 6 6 13

84) For the binarysearch method in Section 6.9.2, what is low and high after the first iteration of the while loop when invoking binarysearch(new int[ ]{1, 4, 6, 8, 10, 15, 20, 11)? A) low is 0 and high is 3 B) low is 4 and high is 6 C) low is 3 and high is 6 D) low is 0 and high is 5 E) low is 0 and high is 6 84) 85) Which of the following lines is not a Java comment? (Choose all that apply.) A) -- comments B) // comments C) ** comments ** D) /** comments */ E) /* comments */ 85) 86) are instructions to the computer. (Choose all that apply.) A) Programs B) Hardware C) Software D) Keyboards 86) 87) Suppose i is an int type variable. Which of the following statements display the character whose Unicode is stored in variable i? A) System.out.println((char)i); B) System.out.println(i); C) System.out.println(i + ʺ ʺ); D) System.out.println((int)i); 87) 88) Which of the following assignment statements is incorrect? (Choose all that apply.) A) i == j == k == 1; B) i = 1 = j = 1 = k = 1; C) i = j = k = 1; D) i = 1; j = 1; k = 1; 88) 89) Suppose x=10 and y=10 what is x after evaluating the expression (y >= 10) (x++ > 10)? A) 10 B) 9 C) 11 89) 90) To add 0.01 + 0.02 +... + 1.00, what order should you use to add the numbers to get better accuracy? A) add 0.01, 0.02,..., 1.00 in this order to a sum variable whose initial value is 0. B) add 1.00, 0.99, 0.98,..., 0.02, 0.01 in this order to a sum variable whose initial value is 0. 90) 91) is a simple but incomplete version of a method. A) A stub B) A main method C) A method developed using top-down approach D) A non-main method 91) 92) If a key is not in the list, the binarysearch method returns. A) insertion point B) -insertion point C) insertion point - 1 D) -(insertion point + 1) 92) 14

93) The main method header is written as: A) public static void main(string[ ] args) B) public static void Main(String[ ] args) C) public static void main(string[ ] args) D) public void main(string[ ] args) E) public static main(string[ ] args) 93) 94) Suppose x is 1. What is x after x -= 1? A) 0 B) 1 C) 2 D) -1 E) -2 94) 95) What is the printout of the following switch statement? char ch = ʹaʹ; switch (ch) { case ʹaʹ: case ʹAʹ: System.out.print(ch); break; case ʹbʹ: case ʹBʹ: System.out.print(ch); break; case ʹcʹ: case ʹCʹ: System.out.print(ch); break; case ʹdʹ: case ʹDʹ: System.out.print(ch); A) aa B) abc C) a D) abcd E) ab 95) 96) Do the following two statements in (I) and (II) result in the same value in sum? 96) (I): for (int i = 0; i<10; ++i) { sum += i; (II): for (int i = 0; i<10; i++) { sum += i; A) Yes B) No 97) Which of the following should be declared as a void method? A) Write a method that returns a random integer from 1 to 100. B) Write a method that checks whether current second is an integer from 1 to 100. C) Write a method that converts an uppercase letter to lowercase. D) Write a method that prints integers from 1 to 100. 97) 15

98) How can you initialize an array of two characters to ʹaʹ and ʹbʹ? (Choose all that apply.) A) char[ ] chararray = new char[2]; chararray = {ʹaʹ, ʹbʹ; B) char[ ] chararray = new char[ ]{ʹaʹ, ʹbʹ; C) char[ ] chararray = {ʹaʹ, ʹbʹ; D) char[2] chararray = {ʹaʹ, ʹbʹ; 98) 99) is a technical definition of the language that includes the syntax and semantics of the Java programming language. A) Java JDK B) Java language specification C) Java API D) Java IDE 99) 100) The method parses a string s to a double value. A) double.parsedouble(s); B) double.parse(s); C) Double.parsedouble(s); D) Double.parseDouble(s); 100) 16

Answer Key Testname: QUIZ 1 1) D ID: jp8 1-25 2) C ID: jp8 1-13 3) A, B, C, D ID: jp8 1-33 4) A, C ID: jp8 1-36 5) A ID: jp8 1-11 6) C ID: jp8 1-34 7) E ID: jp8 1-16 8) C, E ID: jp8 1-24 9) B, D ID: jp8 1-37 10) B ID: jp8 1-17 11) D ID: jp8 1-31 12) B ID: jp8 1-35 13) B, D ID: jp8 1-3 14) A, D ID: jp8 1-15 15) C ID: jp8 2-30 16) C ID: jp8 2-63 17) A ID: jp8 2-55 18) B ID: jp8 2-45 19) C ID: jp8 2-52 20) A ID: jp8 2-65 21) C ID: jp8 2-18 22) A, D ID: jp8 2-40 23) A ID: jp8 2-42 17

Answer Key Testname: QUIZ 1 24) E ID: jp8 2-20 25) D ID: jp8 2-23 26) D ID: jp8 2-22 27) C ID: jp8 3-6 28) D ID: jp8 3-21 29) E ID: jp8 3-32 30) A ID: jp8 3-11 31) C ID: jp8 3-26 32) C ID: jp8 3-37 33) A, B, C, D ID: jp8 3-31 34) A ID: jp8 3-3 35) B ID: jp8 3-27 36) C ID: jp8 3-36 37) E ID: jp8 4-4 38) C ID: jp8 4-24 39) B ID: jp8 4-20 40) E ID: jp8 4-5 41) C ID: jp8 4-8 42) C, E ID: jp8 4-2 43) A ID: jp8 4-12 44) B ID: jp8 4-22 45) D ID: jp8 4-11 46) B ID: jp8 5-10 18

Answer Key Testname: QUIZ 1 47) B ID: jp8 5-5 48) D ID: jp8 5-3 49) C ID: jp8 5-29 50) A ID: jp8 5-9 51) B ID: jp8 5-6 52) D ID: jp8 5-11 53) B ID: jp8 6-38 54) B ID: jp8 6-4 55) D ID: jp8 6-6 56) D ID: jp8 6-30 57) A, B, C ID: jp8 6-34 58) C ID: jp8 6-37 59) A ID: jp8 7-3 60) B ID: jp8 7-2 61) B ID: jp8 7-5 62) A, C ID: jp8 7-6 63) E ID: jp8 7-4 64) A ID: jp8 7-1 65) D ID: jp8 1-2 66) A ID: jp8 1-21 67) B ID: jp8 1-23 68) D ID: jp8 1-20 69) D ID: jp8 1-4 19

Answer Key Testname: QUIZ 1 70) B, D ID: jp8 2-12 71) D ID: jp8 2-36 72) B, C, D ID: jp8 2-2 73) A ID: jp8 2-50 74) C ID: jp8 3-24 75) C ID: jp8 3-4 76) D ID: jp8 3-33 77) A ID: jp8 4-10 78) D ID: jp8 4-1 79) A, D ID: jp8 4-14 80) A ID: jp8 5-16 81) A ID: jp8 5-23 82) D ID: jp8 5-2 83) A ID: jp8 6-32 84) B ID: jp8 6-35 85) A, C ID: jp8 1-32 86) A, C ID: jp8 1-8 87) A ID: jp8 2-49 88) A, B ID: jp8 2-10 89) A ID: jp8 3-20 90) A ID: jp8 4-16 91) A ID: jp8 5-30 92) D ID: jp8 6-36 20

Answer Key Testname: QUIZ 1 93) C ID: jp8 1-22 94) A ID: jp8 2-27 95) C ID: jp8 3-25 96) A ID: jp8 4-9 97) D ID: jp8 5-8 98) B, C ID: jp8 6-10 99) B ID: jp8 1-18 100) D ID: jp8 2-64 21

1) 2) 3) 4) 5) 6) 7) 8) 9) 10) 11) 12) 13) 14) 15) 16) 17) 18) 19) 20) 21) 22) 23) 24) 25) 26) 27) 28) 29) 30) 31) 32) 33) 34) 35) 36) 37) 38) 39) 40) 41) 42) 43) 44) 45) 46) 47) 48) 49) 50) 51) 52) 53) 22

54) 55) 56) 57) 58) 59) 60) 61) 62) 63) 64) 65) 66) 67) 68) 69) 70) 71) 72) 73) 74) 75) 76) 77) 78) 79) 80) 81) 82) 83) 84) 85) 86) 87) 88) 89) 90) 91) 92) 93) 94) 95) 96) 97) 98) 99) 100) 23