Docsity

Computer Programming Exams with Answers 2, Exams of Computer Programming

Toggle sidebar
bg1
First Period Examination - Computer Programming 2
Direction: Read each question carefully then select the letter of the best answer from the
given choices and write it on your respective answer sheet.
I. Multiple Choice.
1. 78:integer ; 74.5:___________
A. String B. Character C. Float D. Boolean
2. “Hello”:___________ ; 143:integer
A. String B. Character C. Float D. Boolean
3. ‘A’:___________ ; 44:integer
A. String B. Character C. Float D. Boolean
4. Amelia is creating a JAVA program that will accept two whole variables and compute and respectively
print their sum. What do you think is the data type she needs to use?
A. String B. Character C. Boolean D. Integer
5. It refers to the values that cannot be change.
A. Variable B. Constant C. Identifier D. Literals
6. It is the keyboard short cut key to create new project.
A. Ctrl + N B. Alt + N C.Alt+Shift+N D. Ctrl+Shift+N
7. What JAVA command are you going to use to be able to create a program that will determine the
Remarks of the inputted grade whether it is Passed or Failed?
A. Loop statement B. If Statement C. Single Array D. Multidimensional array
8. It is a JAVA statement that allows a programmer to execute specific blocks of code a number of times.
A. Command line arguments C. Control structures
B. Repetition control structures D. JAVA arrays
Complete the syntax: For (9.___________; 10.___________; 11. ___________) {
statement 1; statement2; … }
A. Condition B. Execution C. Initialization D. Increment/ decrement
12. It is the section of the For loop statement that updates the loop variable.
A. Condition B. Execution C. Initialization D. Increment/ decrement
13. It is the section of the For loop statement that compares the loop variable to some limit value.
A. Condition B. Execution C. Initialization D. Increment/ decrement
14. It is the section of the For loop statement that prepare the loop variable.
A. Condition B. Execution C. Initialization D. Increment/ decrement
Complete the syntax: 15.___________ while (16.___________) {
statement 1; statement2; …
17.___________ }
A. Condition B. Execution C. Initialization D. Increment/ decrement
18. What will be the output of this code in JAVA programming:
int i=1;
while (i<=3) {
System.out.print(i);
I++; }
A. 1 B. 3 C. 321 D. 123
2 2
3 1
Complete the syntax: 19.___________
do {
statement1; statement2;
20.___________; }
while (21.___________);
A. Condition B. Execution C. Initialization D. Increment/ decrement
22. It is a finite data structure consisting of homogeneous elements or data of the same type and is
referenced with a common name.
A. Loop B. Array C. Polymorphism D. Inheritance
23. It is used to indicate that a variable intArray is an array of a certain data type.
A. { } B. ( ) C. “ “ D. [ ]
24. It is an individual item within an array.
A. index B. array type C. element D. array length
25. In JAVA programming, this part of array always starts with 0(zero).
A. index B. array type C. element D. array length
26. The part of array that refers to the maximum number of elements an array contains.
A. index B. array type C. element D. array length
27. What will be the output of this code in JAVA programming:
pf3
pf4

Partial preview of the text

Download Computer Programming Exams with Answers 2 and more Exams Computer Programming in PDF only on Docsity!

First Period Examination - Computer Programming 2

Direction: Read each question carefully then select the letter of the best answer from the

given choices and write it on your respective answer sheet.

I. Multiple Choice.

  1. 78:integer ; 74.5:___________ A. String B. Character C. Float D. Boolean
  2. “Hello”:___________ ; 143:integer A. String B. Character C. Float D. Boolean
  3. ‘A’:___________ ; 44:integer A. String B. Character C. Float D. Boolean
  4. Amelia is creating a JAVA program that will accept two whole variables and compute and respectively print their sum. What do you think is the data type she needs to use? A. String B. Character C. Boolean D. Integer
  5. It refers to the values that cannot be change. A. Variable B. Constant C. Identifier D. Literals
  6. It is the keyboard short cut key to create new project. A. Ctrl + N B. Alt + N C.Alt+Shift+N D. Ctrl+Shift+N
  7. What JAVA command are you going to use to be able to create a program that will determine the Remarks of the inputted grade whether it is Passed or Failed? A. Loop statement B. If Statement C. Single Array D. Multidimensional array
  8. It is a JAVA statement that allows a programmer to execute specific blocks of code a number of times. A. Command line arguments C. Control structures B. Repetition control structures D. JAVA arrays Complete the syntax: For ( 9 .___________; 10 .___________; 11. ___________) { statement 1; statement2; … } A. Condition B. Execution C. Initialization D. Increment/ decrement
  9. It is the section of the For loop statement that updates the loop variable. A. Condition B. Execution C. Initialization D. Increment/ decrement
  10. It is the section of the For loop statement that compares the loop variable to some limit value. A. Condition B. Execution C. Initialization D. Increment/ decrement
  11. It is the section of the For loop statement that prepare the loop variable. A. Condition B. Execution C. Initialization D. Increment/ decrement Complete the syntax: 15 .___________ while ( 16 .___________) { statement 1; statement2; … 17 .___________ } A. Condition B. Execution C. Initialization D. Increment/ decrement
  12. What will be the output of this code in JAVA programming: int i=1; while (i<=3) { System.out.print(i); I++; } A. 1 B. 3 C. 321 D. 123 2 2 3 1 Complete the syntax: 19 .___________ do { statement1; statement2; 20 .___________; } while ( 21 .___________); A. Condition B. Execution C. Initialization D. Increment/ decrement
  13. It is a finite data structure consisting of homogeneous elements or data of the same type and is referenced with a common name. A. Loop B. Array C. Polymorphism D. Inheritance
  14. It is used to indicate that a variable intArray is an array of a certain data type. A. { } B. ( ) C. “ “ D. [ ]
  15. It is an individual item within an array. A. index B. array type C. element D. array length
  16. In JAVA programming, this part of array always starts with 0(zero). A. index B. array type C. element D. array length
  17. The part of array that refers to the maximum number of elements an array contains. A. index B. array type C. element D. array length
  18. What will be the output of this code in JAVA programming:

Program#1 package javaapplication221; public class JavaApplication221 { public static void main(String[] args) { int[ ] myInts = {5,10,15}; for (int i=0;i=myInts.length;i++){ System.out.println(“The value of myInts[“ + I + “] is: “+ myInts[i]); }

A. 5 C. The value of myInts[0] is: 5 10 The value of myInts[1] is: 10 15 The value of myInts[2] is: 15

B. The value of myInts[1] is: 5 D. 15 The value of myInts[1] is: 10 10 The value of myInts[1] is: 15 5

  1. What do you call the bold and underline part of this code in JAVA programming? Program#2 package javaapplication221; public class JavaApplication221 { public static void main(String[] args) {

int[ ] myInts = {5,10,15} ;

for (int i=0;i=myInts.length;i++){ System.out.println(“The value of myInts[“ + I + “] is: “+ myInts[i]); } A. index B. array type C. element D. array length

Complete this code in JAVA programming: Program#3 package javaapplication143; public class JavaApplication143 { public static void main(String[] args) { 29 .___________= new 30. ___________ [100]; for( 31 .___________=0; wq2<5; wq2 ++ ){ System.out.print(ages 32. ___________); } } } A. int wq2 B.[wq2] C. int D. int[ ] ages

  1. Using JAVA application, what will be the output of the given source code in Program#3? A. 00000 B. 12345 C. 01234 D. 43210
  2. Which of the following is special character is used to display newline? A. \t B. \l C. \n D. \b
  3. Which of the following is special character is used to display double quotation mark? A. \’ B. \ C. * D. \”
  4. Which of the following is special character is used to display backslash? A. \’ B. \ C. * D. \”
  5. It is the system in object oriented programming that allows objects to support operations defined by anterior types without having to provide their own definition which also get the state and behavior in other classes. A. Polymorphism B. Inheritance C. Compile D. Override
  6. It is a keyword in several programming languages used to denote implementation of inheritance. A. Interface B. System C. Extends D. Implements
  7. It is an object-oriented programming language feature that allows a subclass or child class to provide a specific implementation of a method that is already provided by one of its superclasses or parent classes. The implementation in the subclass replaces the implementation in the superclass by providing a method that has same name, same parameters or signature, and same return type as the method in the parent class. A. Polymorphism B. Inheritance C. Compile D. Override
  8. It refers to a principle in biology in which an organism or species can have many different forms or stages. This principle can also be applied to object-oriented programming and languages like the Java language. Subclasses of a class can define their own unique behaviors and yet share some of the same functionality of the parent class. A. Polymorphism B. Inheritance C. Compile D. Override
  9. What will be the output of code in Program#5? A. 1 B. 01 C. 0 D. 01 23 012 00 001 456 0123 000 0001

Answer Key - First Periodic Examination - Computer Programming II

1. C 11. D 21. A 31. A 41. D

2. A 12. D 22. B 32. B 42. * or Scanner

3. B 13. A 23. D 33. A 43. System.in

4. D 14. C 24. C 34. C 44. scan.nextInt

5. B 15. C 25. A 35. C 45. index

6. D 16. A 26. D 36. B 46. int twoD[ ] [ ]

7. B 17. D 27. C 37. B 47. i=

8. B 18. D 28. C 38. C 48. twoD[i][j]

9. C 19. C 29. D 39. D 49. k++

10.A 20. D 30. C 40. A 50. twoD[i][j]+