Java Ch 2

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

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

Addition.java

Given the Java statement: number1 = input.nextInt(); In which number1 is an int and input is a Scanner, which of the following occurs if the user does not enter a valid int value? - A compilation error occurs. - The program continues executing and assigns the value 0 to number1. - An error occurs. - None of the above.

An error occurs.

Which of the following cannot cause a syntax error to be reported by the Java compiler? Mismatched {} Missing */in a comment that begins with /* Missing ; An extra blank line.

An extra blank line.

In Java, arithmetic expressions are evaluated from left to right, no matter what the operators are. (T/F)

False

In your Java program, you can use reserved words as variable names. (T/F)

False

Java is considered a low-level programming language. (T/F)

False

The Java compiler considers payRate to be the same identifier as payrate. (T/F)

False

The Java compiler ignores the underscore character, so walk_home and walk home would be treated as the same identifier. (T/F)

False

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

Hello World

Which of the following is not a valid Java identifier? my Value $_AAA1 width m_x

My Value (Note: can't have two separate words as a variable)

Which of the following statements is false? - Primitive types are keywords. - Primitive types must appear in all lowercase letters. - Real numbers contain decimal points. - Variable name identifiers must begin with a lowercase letter.

Real numbers contain decimal points.

Which of the following statements will print a single line containing "hello there"? System.out.println( "hello" ); System.out.println( " there" ); System.out.println( "hello" , " there" ); System.out.println( "hello" ); System.out.print( " there" ); System.out.print( "hello" ); System.out.println( " there" );

System.out.print( "hello" ); System.out.println( " there" );

Which of the following statement displays Hello World? System.out.printf( "%2s", "Hello " "World" ); System.out.printf( "%s %s", "Hello", "World" ); System.out.printf( "%s%s", "Hello, World" ); System.out.printf( "s% s%", "Hello", "World" );

System.out.printf( "%s %s", "Hello", "World" );

Which of the following does not contain a syntax error? System.out.println( 'Hello world!' ): System.out.println( "Hello world!" ); System.out.println( "Hello world!" ); System.out.println( Hello world! );

System.out.println( "Hello world!" );

Which of the following statements would display the phase "Java is fun"? System.out.println( "hellois fun\rJava " ); System.out.println( 'Java is fun' ); System.out.println( "\"Java is fun\"" ); System.out.println( Java is fun );

System.out.println( "\"Java is fun\"" );

An identifier in Java must begin with a letter, underscore, or a dollar sign and include only letters, numbers, and the underscore; no punctuation characters or spaces are allowed. (T/F)

True

In Java, arithmetic expressions are evaluated from left to right when the precedence of the operators are the same. (T/F)

True

Java is a case-sensitive language (T/F)

True

The syntax of a particular computer language is a set of rules defining the grammar of that language. (T/F)

True

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

Two forward slashes ( //).

Which of the following is the escape character? * \ \n "

\

Which of the following escape sequences represents a carriage return? \n \r \cr \c

\r

All import declarations must be placed...

before the class declaration.

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

commas

Which of the following is a variable declaration statement? int total; import java.util.Scanner; public static void main( String args[] ) // first string entered by user

int total;

Which command executes the Java class file Welcome.class? java welcome java Welcome.class java Welcome run Welcome.class

java Welcome

Which command compiles the Java source code file Welcome.java? cd Welcome.java javac Welcome.java java Welcome.java compile Welcome.jav

javac Welcome.java

Which of the following is a Scanner method for inputting an integer value? nextInteger integer nextInt int

nextInt

Java's predefined classes are grouped into ________

packages

Which of the following is not a Java primitive type? char byte real double

real


संबंधित स्टडी सेट्स

Anatomy & Physiology Chapter 12 Homework

View Set

1 - Accounting: The Language of Business

View Set

Network+ Chapter 5 Networking Devices

View Set