Deck 2: Introduction to Java Applications
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/23
Play
Full screen (f)
Deck 2: Introduction to Java Applications
1
Which of the following escape sequences represents a carriage return?
A)\n.
B)\r.
C)\cr.
D)\c.
A)\n.
B)\r.
C)\cr.
D)\c.
B
2
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
System.out.println( "World" );
A)Hello World
B)HelloWorld
C)Hello World
D)World Hello
A
3
Which command executes the Java class file Welcome.class?
A)javac Welcome.class
B)java Welcome.class
C)java Welcome
D)run Welcome.class
A)javac Welcome.class
B)java Welcome.class
C)java Welcome
D)run Welcome.class
C
4
What is the value of result after the following Java statements execute? int a,b,c,d,result;
A = 4;
B = 12;
C = 37;
D = 51;
Result = d % a * c + a % b + a;
A)119
B)51
C)127
D)59
A = 4;
B = 12;
C = 37;
D = 51;
Result = d % a * c + a % b + a;
A)119
B)51
C)127
D)59
Unlock Deck
Unlock for access to all 23 flashcards in this deck.
Unlock Deck
k this deck
5
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.
A)inside the class declaration's body.
B)before the class declaration.
C)after the class declaration.
D)all of the above will work.
Unlock Deck
Unlock for access to all 23 flashcards in this deck.
Unlock Deck
k this deck
6
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
A)cd Welcome.java
B)javac Welcome.java
C)java Welcome.java
D)compile Welcome.java
Unlock Deck
Unlock for access to all 23 flashcards in this deck.
Unlock Deck
k this deck
7
________ enables a program to read data from the user.
A)printf.
B)import declaration.
C)Scanner.
D)main.
A)printf.
B)import declaration.
C)Scanner.
D)main.
Unlock Deck
Unlock for access to all 23 flashcards in this deck.
Unlock Deck
k this deck
8
Which of the following is the escape character?
A)*
B)\
C)\n
D)"
A)*
B)\
C)\n
D)"
Unlock Deck
Unlock for access to all 23 flashcards in this deck.
Unlock Deck
k this deck
9
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 );
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 );
Unlock Deck
Unlock for access to all 23 flashcards in this deck.
Unlock Deck
k this deck
10
Which of the following is not a Java primitive type?
A)char
B)byte
C)real
D)double
A)char
B)byte
C)real
D)double
Unlock Deck
Unlock for access to all 23 flashcards in this deck.
Unlock Deck
k this deck
11
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! );
A)System.out.println( 'Hello world!' ):
B)System.out.println( "Hello world!" );
C)System.out.println( "Hello world!" );
D)System.out.println( Hello world! );
Unlock Deck
Unlock for access to all 23 flashcards in this deck.
Unlock Deck
k this deck
12
Which of the following is not a valid Java identifier?
A)my Value
B)$_AAA1
C)width
D)m_x
A)my Value
B)$_AAA1
C)width
D)m_x
Unlock Deck
Unlock for access to all 23 flashcards in this deck.
Unlock Deck
k this deck
13
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" );
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" );
Unlock Deck
Unlock for access to all 23 flashcards in this deck.
Unlock Deck
k this deck
14
Which of the following statements does not alter a memory location?
A)int a;
B)number = 12;
C)y = y + 2;
D)width = Integer.parseInt(input);
A)int a;
B)number = 12;
C)y = y + 2;
D)width = Integer.parseInt(input);
Unlock Deck
Unlock for access to all 23 flashcards in this deck.
Unlock Deck
k this deck
15
Which of the following statements will print a single line containing "hello there"?
A)System.out.println( "hello" ); System.out.println( " there" );
B)System.out.println( "hello" ," there" );
C)System.out.println( "hello" ); System.out.print( " there" );
D)System.out.print( "hello" ); System.out.println( " there" );
A)System.out.println( "hello" ); System.out.println( " there" );
B)System.out.println( "hello" ," there" );
C)System.out.println( "hello" ); System.out.print( " there" );
D)System.out.print( "hello" ); System.out.println( " there" );
Unlock Deck
Unlock for access to all 23 flashcards in this deck.
Unlock Deck
k this deck
16
When method printf requires multiple arguments,the arguments are separated with ________.
A)colons (:).
B)semicolons (;).
C)commas (,).
D)periods (. ).
A)colons (:).
B)semicolons (;).
C)commas (,).
D)periods (. ).
Unlock Deck
Unlock for access to all 23 flashcards in this deck.
Unlock Deck
k this deck
17
The format specifier ________ is a placeholder for an int value?
A)%a
B)%d
C)%int
D)%s
A)%a
B)%d
C)%int
D)%s
Unlock Deck
Unlock for access to all 23 flashcards in this deck.
Unlock Deck
k this deck
18
Which of the following cannot cause a syntax error to be reported by the Java compiler?
A)Mismatched {}
B)Missing */ in a comment that begins with /*
C)Missing ;
D)An extra blank line.
A)Mismatched {}
B)Missing */ in a comment that begins with /*
C)Missing ;
D)An extra blank line.
Unlock Deck
Unlock for access to all 23 flashcards in this deck.
Unlock Deck
k this deck
19
Which of the following is not an arithmetic operator?
A)+
B)-
C).
D)%
A)+
B)-
C).
D)%
Unlock Deck
Unlock for access to all 23 flashcards in this deck.
Unlock Deck
k this deck
20
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
A)int total;
B)import java.util.Scanner;
C)public static void main( String args[] )
D)// first string entered by user
Unlock Deck
Unlock for access to all 23 flashcards in this deck.
Unlock Deck
k this deck
21
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.
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.
Unlock Deck
Unlock for access to all 23 flashcards in this deck.
Unlock Deck
k this deck
22
What will be output after the following Java statements have been executed? int a,b,c,d;
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
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
Unlock Deck
Unlock for access to all 23 flashcards in this deck.
Unlock Deck
k this deck
23
Each of the following is a relational or equality operator except:
A)<=
B)=!
C)==
D)>
A)<=
B)=!
C)==
D)>
Unlock Deck
Unlock for access to all 23 flashcards in this deck.
Unlock Deck
k this deck