You are on page 1of 62

LONG QUIZ in COMPUTER

PROGRAMMING (JAVA NCIII)


How come that 1+2 = 4?
1. What kind of programming
language is Java?
A. An object-oriented programming language
B. An array programming language
C. A logic programming language
D. A procedural language
2. What is a variable?
A. An unpredictable element in a Java program
B. A program that can run fast or slow
depending on user input
C. A way to hold data temporarily in a program
D. A software
3. Determine the value of x?
int x = 10; System.out.println(x++);
A. 10
B. 11
C. 9
D. no output
4. Why do you think it is important to
install Operating System (OS)?
A. it manages computer hardware and software
resources
B. it is used to print document
C. it is where the software is stored
D. it is used to speed up the process
5. What would happen if the computer
has no storage devices such as Hard Disk
Drive?
A. it will not boot the operating system
B. you can’t save files
C. it will function properly
D. you can edit the documents
6. It is a class used to obtain the input.
A. Scanner
B. Inheritance
C. Print
D. Input
7. How will you instantiate a variable
input from a Scanner class?
A. Scanner input = Scanner()
B. Scanner input()
C. Scanner input = new Scanner()
D. input()
8. How would you access a value of a
variable?
A. Sytem.out.print(var)
B. System.out.print(“var”)
C. System.in(var)
D. System.in(“var”)
9. How would you display a text and a
value of variable in the same line?
A. System.out.print(“text + value”);
B. System.out.println(“text + value”);
C. System.out.print(“text” +value);
D. System.out.println(“text” + “value”);
10. Which of the following is a legal
identifier?
A. 1Program!
B. Program_1
C. 1program
D. Program 1
11. What would be displayed as a result of the
following code, assuming x has been declared An
integer?
x=578;
System.out.print("There are " + x + "5" + "hens in
the hen house.");
A. There are 583 hens in the hen house
B. There are 5785 hens in the hen house
C. There are x5\nhens in the hen house
D. There are 5785hens in the hen house
12. Explain what is looping statement?
A. allows to execute a statement multiple times
B. main part of the class
C. it is used to terminate a program
D. used to end a statement
13. Choose the best definition of an object.
A. a thing
B. something you wear
C. an instance of a class
D. a blueprint
14. It is the process of removing errors
found in the program.
A. Editing
B. Debugging
C. Compiling
D. Running
15. What is the most important method in
the Java program?
A. System.out.print()
B. main()
C. Scanner()
D. System.in
16. Which Java logical operator checks
either values are true, but not both?
A. OR
B. NOR
C. AND
D. NOT
17. Which of the following is the data type used
for a single character?

A. Byte
B. Short
C. Long
D. Char
18. Which of the following is an invalid first
character of an identifier?
A. _
B. $
C. A
D. 8
19. Which of the following means that in order
for the conditional to happen, either x must be
less than 3 or y must be greater than or equal
to 4?
A. if ((x < 3) && (y > 4))
B. if (x < 3 y >= 4)
C. if ((x < 3) || (y > = 4))
D. if ((x > 3) || (y < = 4))
 20. Which symbol is used to denote a multi-
line comment?

A. / /
B. /* */
C. { }
D. < >
21. What is the smallest unit of
measurement used to quantify computer
data. 
A.terabyte
B. bit
C. byte
D.gigabyte
22. It is the Java keyword that creates
inheritance.
A. Enlarge
B. Extends
C. Inherits
D. Inheritance
23. It is the code/s inside a pair of curly
braces.
A. Block
B. Brick
C. Function
D. Method
24. It is the rules of a programming
language.
A. Format
B. Logic
C. Object
D. Syntax
25. A list of instructions that enable a
computer to perform a specific task is a...
A.Computer Program
B. Algorithm
C. Machine Code
D.Binary Code
26. How many times will the following code print “Hello
World"?
int count = 0;
while (count < 10) {
 System.out.println(“Hello World");
 count++;
}

A. 8
B. 9
C. 10
D. 0
27. The following loop displays______________.
for (int i = 1; i <= 10; i++) {
 System.out.print(i + " ");
 i++;
}
A. 1 2 3 4 5 6 7 8 9
B. 1 2 3 4 5 6 7 8 9 10
C. 1 2 3 4 5 
D. 1 3 5 7 9
28. What is returned by values[7]?

A. 9
B. 12
C. 6
D. error
29. The range of indices for an array always
start at:

A. Whatever programmer specifies


B. 1
C. 0
D. Size of array
30. What's the extension for a
compiled Java file?
A. .class
B. .java
C. .xml
D. .css
31. What's the common term for an error
within a computer program's code that
prevents it from functioning properly?

A. A glitch
B. A hack
C. A bug
D. A code
32. If we declare int [ ] ar = {1,2,3,4,5,6}; The
size of array ar is:

A. 0
B. 5
C. 6
D. 7
33. Object-Oriented Programming means ...
A. Being objective about what you develop
B. Designing the application based on the objects
discovered when analysing the problem
C. Writing an algorithm before writing your program
and having a test plan
D. Writing a program composed of Java classes
34. An array holds:

A. Similar values of same data type


B. Different values of same data type
C. Same values of different data types
D. Different values of different data types
35. The most common use of an array is to:

A. Perform for loop on array


B. Perform different operations on each element in
array
C. Perform the same operation on all elements in array
D. Perform while loop on array
36. Choose the appropriate data type for this
value: "volatile"

A. Int
B. String
C. Double
D. Boolean
37. Choose the appropriate data type for this
value: true

A. Int
B. Double
C. String
D. Boolean
38. Choose the appropriate data type for this
value: 1

A. Int
B. Double
C. String
D. Boolean
39. Choose the appropriate data type for this
value: 5.5

A. Int
B. Double
C. Boolean
D. String
40. Choose the appropriate data type for this
value: ‘A’

A. Int
B. Char
C. Boolean
D. String
41. Which of the following always need a
Capital letter ?
A. Class names and Strings
B. Objects and class names
C. Fields and Strings
D. Data types and fields
42. What is the keyword used in java to
create an object?
A. This
B. New
C. Sync
D. New()
43. What is the correct syntax for java
main method?
A. Public void main(String[] args)
B. Public static void main(string[] args)
C. Public static void main()
D. None of the above
44. Java runs on _______.
A. Windows
B. Unix/Linux
C. Mac 
D. All of the Above
45. Which of the following individuals is
credited for first designing Java?
A.Tim Ritchey
B. James Gosling
C. Jim LeValley
D.Ian Sheeler
46. What is the main function of any
variable ?
A. To add numbers together
B. To keep track of data in the memory of the
computer
C. To print words on the screen
D. To write Java codes
47. What is the proper way to declare a
variable ?
A. VariableName variableType;
B. VariableName;
C. VariableType;
D. VariableType variableName;
48. What is an assignment statement ?
A. Adding a number to an int
B. Assigning a multiplication
C. Assigning a name to a variable
D. Assigning a value to a variable
49. If you want your conditional to depend on two
conditions BOTH being true, what is the proper
notation to put between the two Boolean
statements?

A. &
B. &&
C. |
D. ||
50. Which is NOT a section of all types of
loops ?
A. Initialization
B. Loop Body
C. Test statement
D. The word "while"
Using the declaration below, what will be the final
element of the array? int [ ] grades = new int[35];
A. Grades[0]
B. Grades[34]
C. Grades[35]
D. Impossible to tell
If A=10, then after B=++A, the value of B is
_______.

A. 10
B. 11
C. 12
D. 13
It terminates every line of code in Java.
A. }
B. )
C. ;
D. .
Which is the first program run on a computer
when the computer boots up?
A. System software
B. Operating system
C. System operations
D. None
What is a Computer System made up of?

A. System software and application software


B. System unit and peripherals
C. Hardware and Software
40. What output is produced by the segment
of code shown below: 
int x = 25;
if (x == 25)
  System.out.print(“HELLO");
else
  System.out.print(“HI");
What output is produced by the segment of
code shown below: 
int x = 12;
if (x != 12)
System.out.print("YES");
else
System.out.print("NO");
What output is produced by the segment of
code shown below: 

double Max = 12.7;


if (Max >= 12)
System.out.print(“TRUE");
else
System.out.print("FALSE");
Analyze the following code.
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 B 


B.  count < 100 is always false at Point B
C.  count < 100 is always true at Point A  and count < 100 is always false
at Point C
D. count < 100 is always true at Point C
What is the output for y?
int y = 0;
for (int i = 0; i<10; ++i) {
 y += i;
}
System.out.println(y);
A. 1
B. 36
C. 45
D. 9

You might also like