Chapter 2: Introduction to Java Applications

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

_____ begins an end-of-line comment.

//

_______, __________, and ________ are called white space.

Blank lines, space characters, and tab charactes Book: Space characters, newline, and tab

Is this true or false? (If false, explains why) d) The remainder operator (%) can be used only with integer operands.

False. As long as you specify the variable type that will hold the result. You can use the remainder operator with any number/variable types

Is this true or false? (If false, explains why) f) The identifier ___ (underscore) is valid in java 9.

False. Identifier must contain letters

Is this true or false? (If false, explains why) c) Java considers the variables number and NuMBEr to be identical

False. Java is case sensitive and it treats upper and lower case letters differently.

Is this true or false? (If false, explains why) e) The arithmetic operators *, /, %, +, and - all have the same level of precedence.

False. The precedence is the same as regular arithmetic. For example, () has precedence over *, which has precedence over +/, etc.

Is this true or false? (If false, explains why) a) Comments cause the computer to display the text after the // on the screen when the program executes

False. Any comments made with // at the beginning is ignored by the compiler, because their purpose is for readability and personal notes by the programmer

Write statements to accomplish each of the following tasks: f) If the variable number is not equal to 7, display "The variable number is not equal to 7"

If(number != 7){System.out.printf("The variable number is not equal to 7");}

Methods ______, ________ and ________ display information in a command window.

System.out, System.out.println, System.out.printf

Write statements to accomplish each of the following tasks: e) Print "This is a Java program" on two lines in the command window. The first line should end with Java. Use method System.out printf and two %s format specifiers.

System.out.printf("%s%n%s%s%n", "This is a Java program");

Write statements to accomplish each of the following tasks: b) Prompt the user to enter an integer

System.out.printf("Enter an integer);

Write statements to accomplish each of the following tasks: d) Print "This is a Java program" on one line in the command window. Use method System.out.println.

System.out.println("This is a Java program");

Is this true or false? (If false, explains why) b) all variables must be given a type when they're declared

True

You can use the ____ statement to make decisions,

if

Write statements to accomplish each of the following tasks: a) Declare variables c, thisIsaVariable, q76354 and number to be of type int and initialize each to 0.

int c = 0; int thisIsaVariable = 0; int q76354 = 0; int number = 0;

________ are reserved for use by Java.

keywords

Java application begin execution at method ________.

main

Write statements to accomplish each of the following tasks: c) Input an integer and assign the results to int variable value. Assume Scanner variable input can be used to read a value from the keyboard

variable = stdin.nextInt();

A(n) ____ and a(n) _____ begin and end the body of every method.

{ and } (left and right braces)


Kaugnay na mga set ng pag-aaral

Alabama Drivers Manual Terms, Alabama Driver Manual Test

View Set

APES Review Earth Systems and Resources

View Set