Ch. 2 – Java Fundamentals

Your page rank:

Total word count: 735
Pages: 3

Calculate the Price

- -
275 words
Looking for Expert Opinion?
Let us have a look at your work and suggest how to improve it!
Get a Consultant

Which one of the following would contain the translated Java byte code for a program named Demo?

Demo.class

To compile a program named First, use the following command:

javac First.java

A Java program must have at least one of these:

Class definition

In Java, the beginning of a comment is marked with:

//

The term ___________ typically refers to the device that displays console output.

Standard output device

In Java, ___________ must be declared before they can be used.

Variables

This is a value that is written into the code of a program

Literal

When the (+) operator is used with strings, it is known as the:

String concatenation operator

Which of the following is NOT a rule that must be followed when naming identifiers?

Identifiers can contain spaces.

Which of the following cannot be used as identifiers in Java?

Key words

In Java, it is standard practice to capitalize the first letter of:

Class names

Which of the following is not a primitive data type?

String

Which of the following is valid?

float w; w = 1.0f;

The boolean data type may contain values in the following range of values:

True or False

Character literals are enclosed in _____; string literals are enclosed in _____.

Single quotes; Double quotes

What is the result of the following expression? 10 + 5 * 3 – 20

5

What is the result of the following expression? 25 / 4 + 4 * 10 % 3

7

In the following Java statement what value is stored in the variable name?

String name = "John Doe";

The memory address where "John Doe" is located

Which of the following is not a valid comment statement?

*/ comment 3 /*

When saving a Java source file, save it with an extension of:

.java

Every Java application program must have:

a method named "main"

To print "Hello, world" on the monitor, use the following Java statement:

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

To display the output on the next line, you can use the println method or use this escape sequence in the print method.

\n

This is a named storage location in the computer’s memory.

Variable

Variables are classified according to their:

Data type

The primitive data types only allow a(n) _____ to hold a single value.

Variable

If x has been declared an int, which of the following statements is invalid?

x = 1,000; NO COMMAS!

Given the declaration double r;, which of the following statements is invalid?

r = 2.9X106;

Variables of the boolean data type are useful for:

Evaluating true/false conditions

What is the result of the following expression? 25 – 7 * 3 + 12 / 3

8

What is the result of the following expression? 17 % 3 * 2 – 12 + 15

7

This is a variable whose content is read only and cannot be changed during the program’s execution.

Named constant

Which of the following is a valid Java statement?

String str = "John Doe";

Which of the following does NOT describe a valid comment in Java?

Multi-line comments, start with */ and end with /*

Which of the following statements correctly creates a Scanner object for keyboard input?

Scanner keyboard = new Scanner(System.in);

Which Scanner class method reads an int?

nextInt()

Which Scanner class method reads a String?

nextLine()

Which one of the following methods would you use to convert a string to a double?

Double.ParseDouble

TRUE/FALSE: A Java program will not compile unless it contains the correct line numbers.

False

TRUE/FALSE: All Java statements end with semicolons.

False

TRUE/FALSE: Java is a case-insensitive language.

False

TRUE/FALSE: Although the dollar sign is a legal identifier character, you should not use it because it is normally used for special purposes.

True

TRUE/FALSE: Assuming that pay has been declared a double, the following statement is valid.
pay = 2,583.44;

False

TRUE/FALSE: Named constants are initialized with a value, that value cannot be changed during the execution of the program.

True

TRUE/FALSE: A variable’s scope is the part of the program that has access to the variable.

True

TRUE/FALSE: In Java the variable named total is the same as the variable named Total.

False

TRUE/FALSE: Class names and key words are examples of variables.

False

TRUE/FALSE: Both character literals and string literals can be assigned to a char variable.

False

TRUE/FALSE: If the compiler encounters a statement that uses a variable before the variable is declared, an error will result.

True

TRUE/FALSE: Programming style includes techniques for consistently putting spaces and indentation in a program so visual cues are created.

True

Share This
Flashcard

More flashcards like this

NCLEX 10000 Integumentary Disorders

When assessing a client with partial-thickness burns over 60% of the body, which finding should the nurse report immediately? a) ...

Read more

NCLEX 300-NEURO

A client with amyotrophic lateral sclerosis (ALS) tells the nurse, "Sometimes I feel so frustrated. I can’t do anything without ...

Read more

NASM Flashcards

Which of the following is the process of getting oxygen from the environment to the tissues of the body? Diffusion ...

Read more

Unfinished tasks keep piling up?

Let us complete them for you. Quickly and professionally.

Check Price

Successful message
sending