Sei sulla pagina 1di 8

1.

When a program runs on a computer, the part of the computer that carries out the instructions
is called the CPU

2. When a program is not running, it is stored:


a. on a disk.
b. in level-2 cache (L2).
c. in main memory.
d. on the ethernet or wifi.

3. Flash drives, CDs, external disks are all examples of external storage (memory) devices.

4. At each step of its operation, the input to a Central Processing Unit is


a. a program.
b. an instruction.
c. main memory.
d. a control unit.

5. A binary digit
a. is either positive or negative.
b. is zero or one.
c. requires one byte of storage.
d. is 2.
e. is none of the above.

6. A bit is
a. a metalic rod inserted into a horses mouth to control it while riding.
b. a small amount of data.
c. an alternative term for byte.
d. an electronic device used in computers.
e. a binary digit, like 0 or 1.

7. A byte in memory is identified by a unique number called its address.

8. In modern computer systems, a byte consists of 8 bits.


9. A compiler:
a. maintains a collection of programs
b. tests a program's logic
c. translates source code into executable code
d. translates executable code to machine code

10. In object-oriented programming a class is:


a. a group of people sharing the same relationship to the means of production.
b. the term used for program.
c. a model or template from which objects are created.
d. a grouping of users sharing common objectives.
e. a procedure for a calculation inside a program.

11. In object-oriented programming a method is:


a. a design technique for creating classes.
b. a disciplined way of writing programs.
c. an approach developed by the great Stanislawski.
d. a process for instantiating an object.
e. code that allows access to an object's attributes or that carries out some other action
for the object.

12. An operating system:


a. is the chief hardware unit in a computer.
b. is loaded into the computer each time it needs to carry out an operation.
c. ensures that programs will not run on the computer at the same time.
d. allocates resources like memory to programs that are running.
e. all of the above.

13. What best defines a "programming language"?


a. It allows us to control a computer.
b. It allows us to make a calculation.
c. It allows to execute a program.
d. It allows us to express an algorithm.

14. Which of these is not a programming language?


a. C
b. C++
c. HTML
d. Java
15. The code that a programmer writes is called source code.

16. The ability of a language to let a programmer develop a program on computer system that can
be run on other systems is called portability.

17. To run a Java program from a command line, we use the java command.

18. Files containing Java code must end with what "extension"? .java.

19. The standard name of the Java compiler is javac.

20. Division by zero when the program is executing is an example of a run-time error.

21. The purpose of testing a program with different combinations of data is to expose run-time and
logic errors.

22. A comment starts with what characters? //

23. The text of a comment:


a. is checked by the compiler for accuracy.
b. must appear in the first line of the program.
c. is printed out when the program runs.
d. can be anything the programmer wants to write.

24. Which of the following lines contains a valid, though not necessarily accurate, comment?
a. int twoPi = 3.14159; /* holds the value of two times pi */
b. int twoPi = 2*3.14159; /* holds the value of two times pi //*
c. int twoPi = 2*3.14159; / / *holds the value of 6 //*
d. double twoPi = 2*3.14159; /* // holds the value of two time pi */ [comment] //

25. Which of the following lines does NOT consist of (a) valid, though boastful, comment(s)?
a. // /* This is a */ First Rate Program
b. //**// This is a //**// First Rate Program //**//
c. //* This is a //*// First Rate Program //*//
d. /* This is a //*// First Rate Program //*//

26. We hope you never have to encounter anything like the following expression in a program, but
consider it for a moment and indicate its value: ( /* 5 + 3 */ - 9 + 6/*8*//2 ) //*+4*/ -10
a. 3
b. -7
c. -6
d. 5
e. -8

27. Which comment below is the most helpful?


a. int volume; // declare an int
b. int volume; // declare volume
c. int volume; // declare volume to be an int variable
d. int volume; // size of trunk in cubic feet

28. Which of the following is NOT a legal identifier?


a. outrageouslyAndShockinglyLongRunon
b. _42
c. _
d. lovePotionNumber9
e. 7thheaven

29. Which of the following IS a legal identifier?


a. 5_And_10
b. Five_&_Ten
c. ____________
d. LovePotion#9
e. "Hello World"

30. An identifier that cannot be used as a variable name is a reserved word.

31. Which of the following names in a program is equivalent to the name int?
a. Int
b. INT
c. All of the above
d. None of the above

32. Which of the following is NOT a Java reserved word?


a. public
b. int
c. main
d. static
e. void

33. The rules that govern the correct order and usage of the elements of a language are called the
syntax of the language

34. An error in a program that involves a violation of language rules will be detected at compile
time.

35. Which token is a literal?


a. 77
b. main
c. int
d. +
e. salary

36. Which token is NOT a keyword (language-determined identifier)?


a. int
b. sum
c. double
d. return
e. char

37. The character escape sequence to force the cursor to go to the next line is: \n

38. The character escape sequence to force the cursor to advance forward to the next tab setting is:
\t

39. The character escape sequence to represent a single quote is: \'
40. The character escape sequence to represent a double quote is: \"

41. The character escape sequence to represent a backslash is: \\

42. Before a variable is used it must be


a. defined
b. declared
c. imported
d. evaluated
e. assigned

43. Which is the best identifier for a variable to represent the amount of money your boss pays you
each month?
a. notEnough
b. wages
c. paymentAmount
d. monthlyPay
e. money

44. Of the following variable names, which is the best one for keeping track of whether a patient
has a fever or not?
a. temperature
b. feverTest
c. hasFever
d. fever

45. Of the following variable names, which is the best one for keeping track of whether an integer
might be prime or not?
a. divisible
b. isPrime
c. mightBePrime
d. number

46. A location in memory used for storing data and given a name in a computer program is called a
variable because the data in the location can be changed.
47. In Java, an argument is:
a. a logical sequence of statements proving the correctness of a program.
b. information that a method returns to its caller.
c. information provided to a method.
d. a verbal dispute.

48. Consider this code: "int v = 20; --v; System.out.println(v++);". What value is printed, what value
is v left with?
a. 20 is printed, v ends up with 19
b. 19 is printed, v ends up with 20
c. 20 is printed, v ends up with 20
d. 19 is printed, v ends up with 19
e. cannot determine what is printed, v ends up with 20

49. Consider this code: "int s = 20; int t = s++ + --s;". What are the values of s and t?
a. s is 19 and t is 38
b. s is 20 and t is 39
c. s is 19 and t is 39
d. s is 20 and t is 40
e. s is 20 and t cannot be determined

50. You need to write a loop that will repeat exactly 125 times. Which is the preferred loop
construct to use
a. while loop
b. do while loop
c. for loop

51. You need to write a loop that will keep reading and adding integers to a sum, until the sum
reaches or exceeds 21. The numbers are all less than 20 and the sum is initially 0. Which is the
preferred loop construct to use?
a. while loop
b. do while loop
c. for loop

52. You need to write a loop that reads integers and adds them to a sum as long as they are
positive. Once 0 or a negative value is read in your loop terminates. Which is the preferred loop
construct to use?
a. while loop
b. do while loop
c. for loop

53. You have a variable, n, with a non-negative value, and need to write a loop that will keep print n
blank lines. What loop construct should you use?
a. while loop
b. do while loop
c. for loop

54. An array of 1000 integers has been created. What is the largest integer that can be used as an
index to the array?
a. 1001
b. 1000
c. 999

55. Consider the declaration: int v[] = new int[1]; What is the index of the last element of this array?
a. 0
b. 1
c. 2

56. Suppose v is an array with 100 int elements. If 100 is assigned to v[100], what happens?
a. The compiler issues an error message.
b. The compiler issues a warning message.
c. An exception will be thrown when that statement is executed.
d. Another variable or array will be unexpectedly modified.

Potrebbero piacerti anche