PJP Quarter 1 Practice Assessment

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Every letter in a Java keyword is in lowercase? A. true B. false

A

Every statement in Java ends with ________. A. a semicolon (;) B. a comma (,) C. a period (.) D. an asterisk (*)

A

If you forget to put a closing quotation mark on a string, what kind error will be raised? A. a compilation error B. a runtime error C. a logic error

A

Suppose a Scanner object is created as follows: Scanner input = new Scanner(System.in); What method do you use to read an int value? A. input.nextInt(); B. input.nextInteger(); C. input.int(); D. input.integer();

A

The extension name of a Java source code file is A. .java B. .obj C. .class D. .exe

A

Which of these data types requires the most amount of memory? A. float B. int C. char D. boolean

A

________ is a software that interprets Java bytecode. A. Java virtual machine B. Java compiler C. Java debugger D. Java API

A

Which of the following are correct ways to declare variables? (Multiple Answers) A. int length; int width; B. int length, width; C. int length; width; D. int length, int width;

A B

Which of the following are the reserved words? (Multiple Answers) A. public B. static C. void D. class

A B C D

To declare an int variable number with initial value 2, you write A. int number = 2L; B. int number = 2l; C. int number = 2; D. int number = 2.0;

C

To improve readability and maintainability, you should declare _________ instead of using literal values such as 3.14159. A. variables B. methods C. constants D. classes

C

What is the exact output of the following code? double area = 3.5; System.out.print("area"); System.out.print(area); A. 3.53.5 B. 3.5 3.5 C. area3.5 D. area 3.5

C

_______ is the code with natural language mixed with Java code. A. Java program B. A Java statement C. Pseudocode D. A flowchart diagram

C

____________ is the Java assignment operator. A. == B. := C. = D. =:

C

Which of the following are correct names for variables according to Java naming conventions? (Multiple Answers) A. radius B. Radius C. RADIUS D. findArea E. FindArea

A D

Which of the following is a constant, according to Java naming conventions? (Multiple Answers) A. MAX_VALUE B. Test C. read D. ReadInt E. COUNT

A E

The __________ method returns a raised to the power of b. A. Math.power(a, b) B. Math.exponent(a, b) C. Math.pow(a, b) D. Math.pow(b, a)

C

If you enter 1 2 3, when you run this program, what will be the output? import java.util.Scanner; public class Test1 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter three numbers: "); double number1 = input.nextDouble(); double number2 = input.nextDouble(); double number3 = input.nextDouble(); // Compute average double average = (number1 + number2 + number3) / 3; // Display result System.out.println(average); } } A. 1.0 B. 2.0 C. 3.0 D. 4.0

B

To assign a value 1 to variable x, you write A. 1 = x; B. x = 1; C. x := 1; D. 1 := x; E. x == 1;

B

What is the result of 45 / 4? A. 10 B. 11 C. 11.25 D. 12

B

Which of the following assignment statements is correct? (Multiple Answers) A. i = j = k = 1; B. i = 1; j = 1; k = 1; C. i = 1 = j = 1 = k = 1; D. i == j == k == 1;

B

Which of the following statements is correct? A. Every line in a program must end with a semicolon. B. Every statement in a program must end with a semicolon. C. Every comment line must end with a semicolon. D. Every method must end with a semicolon. E. Every class must end with a semicolon.

B

According to Java naming convention, which of the following names can be variables? (Multiple Answers) A. FindArea B. findArea C. totalLength D. TOTAL_LENGTH E. class

B C

Which of the following is a valid identifier? (Multiple Answers) A. $343 B. class C. 9X D. 8+9 E. radius

B E

Which of the following statements is correct to display Welcome to Java on the console? (Multiple Answers) A. System.out.println('Welcome to Java'); B. System.out.println("Welcome to Java"); C. System.println('Welcome to Java'); D. System.out.print('Welcome to Java'); E. System.out.print("Welcome to Java");

B E

The main method header is written as: A. public static void main(string[] args) B. public static void Main(String[] args) C. public static void main(String[] args) D. public static main(String[] args) E. public void main(String[] args)

C

Analyze the following code: public class Test { public static void main(String[] args) { int n = 10000 * 10000 * 10000; System.out.println("n is " + n); } } A. The program displays n is 1000000000000 B. The result of 10000 * 10000 * 10000 is too large to be stored in an int variable n. This causes an overflow and the program is aborted. C. The result of 10000 * 10000 * 10000 is too large to be stored in an int variable n. This causes an overflow and the program continues to execute because Java does not report errors on overflow. D. The result of 10000 * 10000 * 10000 is too large to be stored in an int variable n. This causes an underflow and the program is aborted. E. The result of 10000 * 10000 * 10000 is too large to be stored in an int variable n. This causes an underflow and the program continues to execute because Java does not report errors on underflow.

C

If a program compiles fine, but it produces incorrect result, then the program suffers __________. A. a compilation error B. a runtime error C. a logic error

C

Programming style is important, because ______________. (Multiple Answers) A. a program may not compile if it has a bad style B. good programming style can make a program run faster C. good programming style makes a program more readable D. good programming style helps reduce programming errors

C D

Which of the following lines is not a Java comment? (Multiple Answers) A. /** comments */ B. // comments C. -- comments D. /* comments */ E. ** comments **

C E

-24 % -5 is _____ A. 3 B. -3 C. 4 D. -4 E. 0

D

-24 % 5 is _____ A. -1 B. -2 C. -3 D. -4 E. 0

D

24 % 5 is _____ A. 1 B. 2 C. 3 D. 4 E. 0

D

If a number is too large to be stored in a variable of the double type, it _____________. A. causes overflow B. causes underflow C. causes no error D. cannot happen in Java

D

Math.pow(2, 3) returns __________. A. 9 B. 8 C. 9.0 D. 8.0

D

Suppose you define a Java class as follows: public class Test { } In order to compile this program, the source code should be stored in a file named A. Test.class B. Test.doc C. Test.txt D. Test.java E. Any name with extension .java

D

To declare a constant MAX_LENGTH inside a method with value 99.98, you write A. final MAX_LENGTH = 99.98; B. final int MAX_LENGTH = 99.98; C. double MAX_LENGTH = 99.98; D. final double MAX_LENGTH = 99.98;

D

Which of the following expression results in a value 1? A. 2 % 1 B. 15 % 4 C. 25 % 5 D. 37 % 6

D

-25 % 5 is _____ A. 1 B. 2 C. 3 D. 4 E. 0

E

25 % 1 is _____ A. 1 B. 2 C. 3 D. 4 E. 0

E


Kaugnay na mga set ng pag-aaral

INTRO TO COMPUTER TECHNOLOGY MIDTERM

View Set

Business Law 2 Final Study Guide

View Set

Chapter 48: Next Generation - NGN

View Set

RN Concept-Based Assessment Level 2 Online Practice B

View Set

Chapter 7 Ionic and Metallic Bonding

View Set