CIS260 Summer 2012 - Exam 1 First Name Last Name: MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) is the physical aspect of the computer that can be seen. 1) A) Application program B) Hardware C) Operating system D) Software 2) is the brain of a computer. 2) A) Memory B) Hardware C) Disk D) CPU 3) The speed of the CPU is measured in. (Choose all that apply.) 3) A) gigabytes B) gigahertz C) megahertz D) megabytes 4) One byte has bits. 4) A) 4 B) 8 C) 16 D) 12 5) Computer can execute the code in. 5) A) assembly language B) machine language C) high-level language D) none of the above 6) translates high-level language program into machine language program. A) An assembler B) The operating system C) CPU D) A compiler 6) 7) is an operating system. 7) A) Java B) Ada C) Windows XP D) Visual Basic E) C++ 8) is a program that runs on a computer to manage and control a computer's activities. A) Operating system B) Compiler C) Java D) Modem E) Interpreter 8) 9) is interpreted. 9) A) C B) Pascal C) Ada D) C++ E) Java
10) is Architecture-Neutral. 10) A) Ada B) C++ C) Java D) Pascal E) C 11) 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 language specification B) Java JDK C) Java API D) Java IDE 11) 12) A block is enclosed inside. 12) A) quotes B) parentheses C) brackets D) braces 13) Which of the following statements is correct? 13) A) Every comment line must end with a semicolon. B) Every method must end with a semicolon. C) Every statement in a program must end with a semicolon. D) Every class must end with a semicolon. E) Every line in a program must end with a semicolon. 14) The extension name of a Java source code file is 14) A).exe B).class C).obj D).java 15) Java compiler translates Java source code into. 15) A) assembly code B) Java bytecode C) machine code D) another high-level language code 16) The extension name of a Java bytecode file is 16) A).java B).exe C).class D).obj 17) is a software that interprets Java bytecode. 17) A) Java API B) Java compiler C) Java debugger D) Java virtual machine 18) Suppose a Scanner object is created as follows: 18) Scanner input = new Scanner(System.in); What method do you use to read an int value? A) input.int(); B) input.nextint(); C) input.nextinteger(); D) input.integer();
19) To assign a value 1 to variable x, you write 19) A) 1 := x; B) x == 1; C) x = 1; D) 1 = x; E) x := 1; 20) To declare a constant MAX_LENGTH inside a method with value 99.98, you write A) final float MAX_LENGTH = 99.98; B) final double MAX_LENGTH = 99.98; C) double MAX_LENGTH = 99.98; D) final MAX_LENGTH = 99.98; 20) 21) Which of these data types requires the most amount of memory? 21) A) int B) short C) long D) byte 22) Which of the following expression results in a value 1? 22) A) 25 % 5 B) 2 % 1 C) 37 % 6 D) 15 % 4 23) 25 % 1 is. 23) A) 1 B) 2 C) 3 D) 4 E) 0 24) To declare an int variable number with initial value 2, you write 24) A) int number = 2l; B) int number = 2.0; C) int number = 2; D) int number = 2L; 25) 24 % 5 is. 25) A) 1 B) 2 C) 3 D) 4 E) 0 26) To add number to sum, you write (Note: Java is case-sensitive) (Choose all that apply.) A) sum = sum + number; B) sum = Number + sum; C) number += sum; D) number = sum + number; E) sum += number; 27) What is the printout of the following code: 26) 27) double x = 5.5; int y = (int)x; System.out.println("x is " + x + " and y is " + y); A) x is 6.0 and y is 6.0 B) x is 5 and y is 6 C) x is 6 and y is 6 D) x is 5.5 and y is 5.0 E) x is 5.5 and y is 5 28) What is the value of (double)(5/2)? 28) A) 3 B) 2 C) 3.0 D) 2.5 E) 2.0
29) What is the value of (double)5/2? 29) A) 2.5 B) 2 C) 3 D) 3.0 E) 2.0 30) What is the printout of System.out.println('z' - 'a')? 30) A) 26 B) a C) z D) 25
Java Programming (Tip Calculator) Write a Java program that reads the subtotal and gratuity rate, then computes the tip and total. For example if the user enter 20 and 15, the program displays Tip is $3.00 and Total is $23.00
1) B 2) D 3) B, C 4) B 5) B 6) D 7) C 8) A 9) E 10) C 11) D 12) D 13) C 14) D 15) B 16) C 17) D 18) B 19) C 20) B 21) C 22) C 23) E 24) C 25) D 26) A, E 27) E 28) E 29) A 30) D