Quiz 1 Intro to java variables

¡Supera tus tareas y exámenes ahora con Quizwiz!

javac

Java compiler that converts Java code to Java Virtual machine code

What comparison operator is used for "not equal to"?

The correct answer is !=. The usage would be 3!=9.

Which of the following characters is not allowed for Java variable names? a. backslash b. dollar sign c. capital A d. underscore

The correct answer is backslash. Java variable names can begin with letters, underscores, and dollar signs.

You purchase moving boxes and mark them with labels to indicate the contents they will store. What action describes the labeling of the boxes?

The correct answer is declaring variables. Declaring variables is the process of naming a variable, a temporary holding space for data.

What data type can be used to store decimal numbers in Java?

The correct answer is float. In Java, the float and double data types are used to store decimal numbers.

comparison operator

symbols used in order to create information out of raw data

conditional operator

ternary operator

escape sequence

used in conjunction with a backslash to format program output

The syntax println(): is used to print the contents of its _______ and then print a carriage return to place the cursor on the next line.

In Java, the println(); prints what is in between the () to an output device such as a printer or screen.

The main difference between \f and \r is that the \f produces a _________.

In Java, the escape sequence \f produces a form feed while the \r produces a hard return.

In the statement: [System.out.println("\n This is on one line \n This is on another line");] the \n produces a _________.

In Java, the escape sequence \n produces a linefeed.

In a conditional statement, the _____ symbol is used to separate a test expression from the expression to be processed if the test result is true.

In a conditional statement, the ? separates the true expression from the false expression in the evaluation part of the conditional.

What does the Boolean data type store?

The correct answer is 0s or 1s. The Boolean data type is used to store the digit 1 or 0 to indicate a true or false state, respectively.

Distinguish between exponentiation and modulus. Be specific.

Answers will vary. Your answer must include: exponentiation denotes repeated multiplication while modulus returns the remainder from the quotient of two numbers.

Analyze the following code, which is correct for a conditional operator? a. (myAge>=yourAge)?myAge-yourAge:yourAge-myAge b. (myAge>=yourAge):myAge-yourAge:yourAge-myAge c. (myAge>=yourAge)?myAge-yourAge?yourAge-myAge d. (myAge>=yourAge);myAge-yourAge;yourAge-myAge

The correct answer is (myAge>=yourAge)?myAge-yourAge:yourAge-myAge. The syntax of a conditional operator requires three expressions separated by a question mark and a colon.

Which Java syntax describes the mathematical expression "3 is not equal to 9"?

The correct answer is 3!=9. In Java, "not equal to" is denoted by !=.

What symbol would not be seen in the syntax for Java variables, methods, or arguments?

The correct answer is ??. When writing variable names, methods, and attributes, "??" is invalid syntax.

Why would you not use a char to store the phrase "Super100"?

The correct answer is A char only stores one letter, number, or symbol. In Java, the char data type stores 1 character, while the string data type stores a sequence of characters.

When comparing the comparison operator "equal" to the Java assignment operator, what is the main difference?

The correct answer is The comparison operator is = and the Java assignment operator is ==. A good way to remember this is that a comparison operator requires two elements.

You are writing a payroll program in Java that needs to assign the value of 25 percent as a tax rate. Which statement represents the best construct of this assignment? a. int taxRate == 0.25; b. float taxRate = 0.25; c. float taxRate != 0.25; d. long taxRate = 25;

The correct answer is float taxRate = 0.25;.

You are writing a program that needs to calculate gross pay for an employee based on variables grossPay, payRate, and hrsWorked. Which statement represents the best construct of this assignment? a. grossPay = payRate - hrsWorked; b. grossPay = payRate / hrsWorked; c. grossPay = payRate - hrsWorked; d. grossPay = hrsWorked * payRate;

The correct answer is grossPay = hrsWorked * payRate;. Gross pay can be calculated by multiplying the number of hours worked by the pay rate per hour.

Which operation comes before D in PEMDMAS?

The correct answer is multiplication. PEMDMAS represents the mathematical operations of parentheses, exponentiation, multiplication, division, modulus, addition, and subtraction.

You are declaring a variable that will store text. Which data type could be used for the new variable?

The correct answer is string. String data types store characters.

What term best represents the set of rules that govern the use of words and punctuation in a language?

The correct answer is syntax. Syntax represents the constructs of a language, including the words and grammar that comprise it.


Conjuntos de estudio relacionados

Science Bowl Multiple Choice Practice Questions

View Set

IPC 1B - Lesson Nine: Electromagnetic Waves and Light

View Set

Microbiology Animation 8.4 ABC Transporters

View Set

Immunity, Inflammation, and Hormonal Regulation

View Set