0% found this document useful (0 votes)
84 views

Biñan City Senior High School - San Antonio Campus

This document appears to be a practice test for a computer programming class in Java at Binan City Senior High School - San Antonio Campus in the Philippines. It contains 45 multiple choice questions testing knowledge of Java programming concepts like classes, objects, inheritance, arrays, loops, and exceptions. The test covers defining and using classes, object-oriented principles, variable declaration and assignment, control structures, and basic input/output. It also includes questions about graphical user interface (GUI) components like JFrames and JButtons from the Java Swing library.

Uploaded by

Blue Lions
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views

Biñan City Senior High School - San Antonio Campus

This document appears to be a practice test for a computer programming class in Java at Binan City Senior High School - San Antonio Campus in the Philippines. It contains 45 multiple choice questions testing knowledge of Java programming concepts like classes, objects, inheritance, arrays, loops, and exceptions. The test covers defining and using classes, object-oriented principles, variable declaration and assignment, control structures, and basic input/output. It also includes questions about graphical user interface (GUI) components like JFrames and JButtons from the Java Swing library.

Uploaded by

Blue Lions
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Republic of the Philippines

DEPARTMENT OF EDUCATION
Region IV-A CALABARZON
Schools Division Office of Biñan City
BIÑAN CITY SENIOR HIGH SCHOOL - SAN ANTONIO CAMPUS
Pedro Escueta St., Brgy. San Antonio, City of Biñan, Laguna

SECOND PERIODICAL TEST IN COMPUTER PROGRAMMING (JAVA NCIII)


Grade 12, SY 2019-2020

I. Direction: Choose the letter which corresponds to the best answer. Shade the circle
corresponding to the letter of your answer in the provided answer sheet.
1. The size of a frame is set using ...
A. The method setSize()
B. The width and height attributes of the class JFrame
C. Automatically in run-time
D. WIDTH and HEIGHT properties of menu in Eclipse
2. Which package do you need to use widgets such as JApplet, JFrame, JPanel and JButton?
A. Javax.swing B. Javax.gui C. Java.awt D. Java.swing
3. Which one is not correct?
A. A class needs to be instantiated as an object before being used
B. An object exists in memory in run time
C. Class and object are just different names for the same thing
D. An object is a variable, where its type is the class used to declare the variable
4. Class B inherits from Class A, what cannot be said:
A. B is a sub-class of A C. A is a super-class of B
B. B has access to private members of A D. B has access to protected members of A
5. Which one of the following statements is correct?
A. The ‘try’ block should be followed by a ‘catch’ block.
B. The ‘try’ block should be followed by a ‘finally’ block.
C. The ‘try’ block should be followed by either a ‘catch’ block or a ‘finally’ block.
D. The ‘try’ block should be followed by at least two ‘catch’ blocks.
6. How to create a try-catch block?
A. try() catch() B. try{ catch() } C. try{ } catch(){} D. try: catch()
7. What would happen if a subclass uses the method inside the superclass without using
keyword extends?
A. It will still work because of inheritance
B. Method/s will be unknown to subclass cannot use method/s without extends keyword
C. It will display results even without extends keyword
D. There will be a syntax error
8. Which of the following is use to create an inheritance from a superclass?
A. Subclass extends Superclass C. Subclass implements Superclass
B. Subclass inherits Superclass D. Subclass imports Superclass
9. What is an assignment statement?
A. Adding a number to an int C. Assigning a multiplication
B. Assigning a name to a variable D. Assigning a value to a variable
10. An array holds:
A. Similar values of same data type C. Same values of different data types
B. Different values of same data type D. Different values of different data types
11. What is the proper way to use or declare a variable?
A. var varType; B. varName; C. varType; D. variableType varName;
12. The last value in an array called myArray can be found at index:
A. 0 B. 1 C. Ar.length D. Ar.length – 1
13. What would be displayed from the following statements?
int [ ] nums = {1,2,3,4,5,6}; System.out.println((nums[1] + nums[3]));
A. 6 B. 2+4 C. 1+3 D. 413
14. Given the declaration: int [ ] ar = {1,2,3,4,5}; What is the value of ar[3]?
A. 2 B. 3 C. 4 D. 5
15. The most common use of an array is to:
A. Perform for loop on array C. Perform different operations on each element
B. Perform while loop on array D. Perform the same operation on all elements

School ID: 342242 | Email: [email protected] | Facebook Page: @binancitySHS | Telephone: (049) 511-8164
16. Which of the following always need a capital letter?
A. Class names B. Objects C. Fields and Strings D. Data types
17. The range of indices for an array always start at:
A. Whatever programmer specifies B. 1 C. 0 D. Size of array
18. How to create a JButton with the caption test?
A. JButton aButton('test'); C. JButton aButton=new JButton("test");
B. JButton aButton=new JButton('test'); D. JButton("test") aButton;
19. Explain what a looping statement is.
A. A new type of Applet.
B. A segment of code to be run a specified amount of times
C. A segment of code to be run infinite times
D. A segment of code to be run once
20. If you want your conditional to depend on two conditions BOTH being true, what is the
proper notation to use between the two Boolean statements?
A. & B. && C. | D. ||
21. Which of the following needs to be imported for java jdbc connectivity JFrame project from
netbeans?
A. Javax.sql.*; B. Java.sql.*; C. Javac.sql.*; D. Java.sql;
22. Which keyword is used for implementing inheritance in java?
A. Implements B. Extends C. Inherits D. Derives
23. Class.forName() method is used for?
A. Firing the query B. Connection C. Registering the Driver D. Class Name
24. The following are benefits of the Object-Oriented Programming, EXCEPT:
A. Reliability B. Flexibility C. Maintainability D. Polymorphism
25. What is it called when a program is written to respond to the button clicks, menu selections,
and other actions of the user in whatever order the user does them?
A. Event-driven B. Action-driven C. User-driven D. Mouse-driven
26. What is the one component that nearly all GUI programs will have?
A. Frame B. Mouse C. Monitor D. Button
27. How will you instantiate a variable scan from a Scanner class?
A. Scanner scan = Scanner() C. Scanner scan()
B. Scanner scan = new Scanner() D. scan()
28. Which of the following sets the frame to 300 pixels wide by 200 high?
A. frm.setSize( 300, 200 ); C. frm.setSize( 200, 300 );
B. frm.paint( 300, 200 ); D. frm.setVisible( 300, 200 );
29. What is the appropriate data type for this value: “Username”
A. Int B. Double C. String D. Boolean
30. JTable has which of the following functions?
A. It stores data B. It renders data C. Both A and B D. None of the above
31. Which of the following SQL objects will store the data retrieved through a Query?
A. Connection B. Driver C. Statement D. ResultSet
32. Which of the following statements is false?
A. A subclass is generally larger than its superclass.
B. A superclass object is a subclass object.
C. The class following the extends keyword in a class declaration is the direct superclass of
the class being declared.
D. Java uses interfaces to provide the benefits of multiple inheritance.
33. Which of the following is not a superclass/subclass relationship?
A. Ford/Taurus C. University/Brown University
B. Sailboat/Tugboat D. Country/USA
34. You want to take the input of Hobbies from the user, i.e. sports, movies, traveling etc.
Which of the following controls would be the most suitable?
A. Radio Button B. Check Box C. Text Field D. Combo box
35. What is the result of the following statement? int x=5; System.out.println(x)
A. 5 B. syntax error C. x D. null
36. How would you create a statement that will access a value of a variable?
A. System.out.print(var) C. System.out.print(“var”)
B. System.in(var) D. System.in(“var”)
37. What method sets the size of the displayed JFrame?
A. setSize( int width, int height) C. setSize( int height, int width)

School ID: 342242 | Email: [email protected] | Facebook Page: @binancitySHS | Telephone: (049) 511-8164
B. setVisible( int width, int height) D. setVisible( int height, int width)
38. How would you modify the statement below to have a correct result?
int num = 123.50; System.out.print(num);
A. change print to println C. remove the equal sign
B. change int to double D. change out to in
39. It is an instance of a class.
A. Attribute B. Function C. Method D. Object
40. Which method is used to changes the text the label displays?
A. changeText B. setText C. changeLabel D. setLabel
41. Which symbol is used to denote a multi-line comment?
A. // B. /* */ C. { } D. < >
42. The use of import declaration import *; ________.
A. Causes a compilation error C. Imports all classes in the library
B. Imports the default classes in the library D. Imports the classes in package
43. It is the process of removing errors found in the program.
A. Editing B. Compiling C. Debugging D. Running
44. Which of the following is NOT a Java keyword?
A. Default B. For C. Of D. Volatile
45. Which of the following is an invalid first character of an identifier?
A. __ B. $ C. A D. 8
46. A package is:
A. A directory structure used to organize classes and interfaces
B. A mechanism for software reuse
C. A group of related classes and interfaces
D. All of the above
47. Which of the following has highest operator precedence
A. ++ B. ?: C. << D. &&
48. Failure to prefix the superclass method name with the keyword super and a dot (.)
separator when referencing the superclass’s method causes ________.
A. a compile-time error C. a syntax error
B. infinite recursion D. a runtime error
49. Describe what "string" is.
A. Type of variable that stores text
B. Type of variable that stores text and numbers
C. Type of variable that stores numbers
D. This command does not exist!
50. . Polymorphism is one interface with __________.
A. Single method B. Multiple methods C. Multiple record D. Single record

School ID: 342242 | Email: [email protected] | Facebook Page: @binancitySHS | Telephone: (049) 511-8164
School ID: 342242 | Email: [email protected] | Facebook Page: @binancitySHS | Telephone: (049) 511-8164

You might also like