Filters
Question type

Study Flashcards

Which of the following statements would display the phase Java is fun?


A) System.out.println( "hellois fun\rJava " ) ;
B) System.out.println( 'Java is fun' ) ;
C) System.out.println( "\"Java is fun\"" ) ;
D) System.out.println( Java is fun ) ;

E) A) and D)
F) A) and B)

Correct Answer

verifed

verified

A

Which of the following statement displays Hello World?


A) System.out.printf( "%2s", "Hello " "World" ) ;
B) System.out.printf( "%s %s", "Hello", "World" ) ;
C) System.out.printf( "%s%s", "Hello, World" ) ;
D) System.out.printf( "s% s%", "Hello", "World" ) ;

E) C) and D)
F) B) and D)

Correct Answer

verifed

verified

What will be output after the following Java statements have been executed (assume all variables are of type int) ? A = 4; B = 12; C = 37; D = 51; If ( a < b ) System.out.println( "a < b" ) ; If ( a > b ) System.out.println( "a > b" ) ; If ( d <= c ) System.out.println( "d <= c" ) ; If ( c != d ) System.out.println( "c != d" ) ;


A) a < b c != d
B) a < b d <= c
C != d
C) a > b c != d
D) a < b c < d
A != b

E) A) and C)
F) B) and C)

Correct Answer

verifed

verified

Which of the following is a variable declaration statement?


A) int total;
B) import java.util.Scanner;
C) public static void main( String args[] )
D) // first string entered by user

E) None of the above
F) A) and B)

Correct Answer

verifed

verified

A

The filename for the public class that begins with public class Addition must be


A) public.java.
B) public.class.java.
C) Addition.java.
D) addition.java.

E) B) and C)
F) All of the above

Correct Answer

verifed

verified

Which of the following does not contain a syntax error?


A) system.out.println( 'Hello world!' ) :
B) System. out.println( "Hello world!" ) ;
C) System.out. println( "Hello world!" ) ;
D) System.out.println( Hello world! ) ;

E) None of the above
F) B) and C)

Correct Answer

verifed

verified

Which of the following statements is true?


A) System.out.print("Enter your age: ") ; prompts the user to take action.
B) Class names typically begin with a capital letter.
C) Package java.lang is imported in every Java program.
D) All of the above are true.

E) All of the above
F) A) and B)

Correct Answer

verifed

verified

Which of the following statements is false?


A) Primitive types are keywords.
B) Primitive types must appear in all lowercase letters.
C) Real numbers contain decimal points.
D) Variable name identifiers must begin with a lowercase letter.

E) B) and D)
F) B) and C)

Correct Answer

verifed

verified

D

Which of the following is not an arithmetic operator?


A) +
B) -
C) .
D) %

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

Which command compiles the Java source code file Welcome.java?


A) cd Welcome.java
B) javac Welcome.java
C) java Welcome.java
D) compile Welcome.java

E) B) and D)
F) C) and D)

Correct Answer

verifed

verified

A(n) ________ enables a program to read data from the user.


A) printf.
B) import declaration.
C) Scanner.
D) main.

E) B) and D)
F) B) and C)

Correct Answer

verifed

verified

When method printf requires multiple arguments, the arguments are separated with ________.


A) colons (:) .
B) semicolons (;) .
C) commas (,) .
D) periods (.) .

E) B) and D)
F) B) and C)

Correct Answer

verifed

verified

Portions of statements that contain calculations are called


A) variables.
B) constants.
C) expressions.
D) None of the above.

E) B) and C)
F) None of the above

Correct Answer

verifed

verified

Programs remember numbers and other data in the computer's memory and access that data through program elements called


A) comments.
B) messages.
C) integers.
D) variables.

E) A) and B)
F) B) and D)

Correct Answer

verifed

verified

End-of-line comments that should be ignored by the compiler are denoted using


A) Two forward slashes ( // ) .
B) Three forward slashes ( /// ) .
C) A slash and a star ( /* ) .
D) A slash and two stars ( /** ) .

E) A) and B)
F) A) and D)

Correct Answer

verifed

verified

Which is the output of the following statements? System.out.print( "Hello ") ; System.out.println( "World" ) ;


A) Hello World.
B) helloWorld
C) Hello World
D) World hello

E) B) and C)
F) All of the above

Correct Answer

verifed

verified

Which command executes the Java class file Welcome.class?


A) java welcome
B) java Welcome.class
C) java Welcome
D) run Welcome.class

E) None of the above
F) All of the above

Correct Answer

verifed

verified

Which of the following is not a compilation error?


A) Neglecting to initialize a local variable in a method before it is used.
B) Placing a semicolon at the end of the first line of an if statement.
C) Omitting the left and right parenthesis for the condition of an if statement.
D) All are compilation errors.

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

All import declarations must be placed


A) inside the class declaration's body.
B) before the class declaration.
C) after the class declaration.
D) all of the above will work.

E) A) and C)
F) A) and B)

Correct Answer

verifed

verified

Which of the following is not a Java primitive type?


A) char
B) byte
C) real
D) double

E) A) and B)
F) B) and D)

Correct Answer

verifed

verified

Showing 1 - 20 of 34

Related Exams

Show Answer