Section 1

Preview this deck

What is the syntax of a language?

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

1

All-time users

1

Favorites

0

Last updated

1 year ago

Date created

Mar 1, 2020

Cards (163)

Section 1

(50 cards)

What is the syntax of a language?

Front

The rules that determine how words and symbols can be combined

Back

Which of the following is a Java Primitive type?

Front

boolean, int, double

Back

What is debugging?

Front

The process of determining the root cause of a problem and fixing it

Back

_________ is crucial in program style

Front

Consistency

Back

Java was created by a development team led by James Gosling

Front

true

Back

The Java Development Kit (JDK) is a _________ environment

Front

command-line

Back

The int, long, and short data types both represent integers

Front

true

Back

Numeric primitive values in Java are signed.

Front

true

Back

Java programs cannot be run on a web page

Front

false

Back

Java performs automatic garbage collection

Front

true

Back

The end-of-line block style aligns opening and closing braces vertically

Front

False, the end-of-line block style puts the opening brace at the end of the preceding line

Back

Classes in the Java API are organized into packages

Front

true

Back

The Java Virtual machine is software

Front

true

Back

A multi-line comment begins with what?

Front

/ and ends with /

Back

Internally, uppercase and lowercase letters are treated the same

Front

false, they are distinct

Back

Full documentation about the Java API can be found online.

Front

true

Back

The println statement is a call to method

Front

true

Back

In a programming language, a syntactically valid statement has only one meaning

Front

true

Back

Which of the following is NOT a valid Java identifier

Front

1stPlace

Back

Which is not a valid variable declaration in Java

Front

int first = true you can not assign a boolean value to an int variable

Back

Which of the following will produce a syntax error?

Front

Omitting a necessary semicolon in a program

Back

Comments

Front

Provide extra information for humans to read and is ignored by the compiler

Back

Java source code cannot be executed directly by a computer

Front

True, it must be translated

Back

What is programming convention?

Front

A guideline about a program style that makes code easier to read

Back

What is syntax coloring?

Front

Showing certain elements of program code in different colors

Back

Java is an object-oriented programming language

Front

true

Back

What software tool is used to translate Java source code into Java Bytecode

Front

compiler

Back

A Java comment cannot appear on a line that contains an executable statement

Front

false, it can be put after the code to help explain that line

Back

The float -

Front

represents floating point values

Back

Which of the following identifiers follows the convention for naming Java variables

Front

totalValue

Back

Characters in Java are represented by what?

Front

Unicode character set

Back

Sun created Java and was then bought by Oracle

Front

true

Back

A typical Java compiler produces which type of output?

Front

Java bytecode

Back

Which of the following will produce a runtime error?

Front

Dividing by zero

Back

What issue must be addressed when printing a long character strip?

Front

A character string literal cannot span across multiple lines

Back

The main method of a Java program must have which of the following method headers?

Front

public static void main(String[] args)

Back

What are the two categories of data types in Java

Front

Primitive data and object references

Back

System.out.print("Total: " + 100 20);

Front

Total: 10020

Back

What does the import statement do?

Front

Identifies the package in which a class can be found

Back

What is a natural language?

Front

A language that humans use to communicate, such as English

Back

Difference between print and println

Front

print- whatever is printed next will be on the same line as what was printed previosly println- moves statement to the next line

Back

Java is a general-purpose programming language

Front

true

Back

Which is true?

Front

The body of a Java method is enclosed in curly braces

Back

What output is produced? System.out.println(15 + 30);

Front

45

Back

How many primitive data types are there?

Front

8

Back

If the computer produces errors, it will not generate an executable version of the program

Front

true

Back

The Java compiler requires all indentation levels to be four spaces

Front

False

Back

The slogan "Write Once, Run Anywhere" is used to promote what?

Front

Java's cross platform benefits

Back

Using the Java API in a program is rare

Front

false

Back

What is the Java API/

Front

A large library of classes

Back

Section 2

(50 cards)

An import statement should be written inside a class but before any methods.

Front

true, it should be written above the class

Back

The first parameter to printf is

Front

the format string

Back

What is the result 43 % 5

Front

3

Back

An import statement tells the compiler which class you're referring to in a program.

Front

true

Back

If the current value of the integer variable num1 is 2 and the current value of the double variable num2 is 3.0, what value will be stored in num2 after the following line of code is executed? num2 /= num1 * num2

Front

0.5 2*3.0=6.0 3.0/6.0=0.5

Back

If both operands to the remainder operator (%) are positive, a divisor of n will produce a result in the range 1 to n

Front

False, range is 0 to n-1

Back

Two classes can have the same name if they are in different packages.

Front

true

Back

If the current value of the integer variable count is 2, what value will be stored in count after the following line of code is executed? count += count * 3;

Front

8 2+2*3= 8

Back

What is the result of the expression Math.pow(3, 3)?

Front

27

Back

What will the result of 7 / 2

Front

3

Back

What is the result of the expression Math.floor(12.843)?

Front

12

Back

If either or both operands to the division operator are floating-point values, then the result will be a floating-point value

Front

true

Back

The byte data type represents a true or false value

Front

false, true/false is a boolean

Back

The field width in a printf format specifier determines the total number of characters to be used to print the value.

Front

true

Back

When reading input using a Scanner object, if the type of input does not match the expected type, the compiler will issue an error message.

Front

False, this type of problem cannot be detected during compilation. It is a runtime error

Back

What should you pass to the Scanner constructor if you want to create a Scanner object that reads input typed at the keyboard.

Front

System.in

Back

When reading input using a Scanner object, each input value must be on its own line.

Front

False, depending on what types of values are being read, they might be on the same input line

Back

A printf format specifier changes the value in

Front

the corresponding parameter

Back

If the current value of the integer variable num is 4, what value will be sorted in num after the following line of code is executed? num +=2

Front

6

Back

The expression count++ can stand as a statement on its own

Front

True

Back

Given the following declarations, which assignment statement would cause the compiler to issue an error? int num1 = 5; int num2 = 3500; double num3 = 7.29;

Front

num2 = num3 A double value cannot be assigned to an integer variable without a cast

Back

A printf format specifier of %.3f will print a floating-point value truncated to 3 decimal places.

Front

False, the value is rounded

Back

The assignment operator has higher precedence than the arithmetic operators

Front

False, The assignment operators have the lowest precedence

Back

The printf method accepts a variable number of parameters

Front

true

Back

A constant is created using what?

Front

final modifier

Back

In a program, a class must always be referred to using its fully qualified name.

Front

false,

Back

Which line of code is equivalent to the following? depth += 50 * offset;

Front

depth = depth + (50 * offset);

Back

The Math class contains that represent the value pi to several digits

Front

true

Back

If the current value of the integer variable size is 2, what value will stored in size after the following line of code is executed? size *= 3;

Front

6

Back

Which of the following identifiers follows the naming convention for a Java constant?

Front

MAX_PENALTIES All caps for naming a convention

Back

What happens to the current value of the integer variable size when the following statement is executed?

Front

The current value is overwritten by the new value

Back

A type cast does what?

Front

A cast causes a value to be treated as another type only for the current expression

Back

Any data point in Java can make....

Front

A constant

Back

The method of the Math class is

Front

static

Back

The next and nextLine methods of the Scanner class both read and return character strings.

Front

true

Back

The format method of the String class accepts the same parameters as the printf method. True

Front

true, same format but does not print

Back

The Math.PI constant represents pi to 15 decimal places

Front

true

Back

If the variable num contains a positive integer, what are the only two possible results of the expression?

Front

0 and 1

Back

What value is assigned to the integer variable num by the following statement if the current value of num is 4? num = num * 2;

Front

4

Back

An entire package can be imported using one import statement

Front

true, using the * wildcard character

Back

The expression x^y raises the value x to the power y

Front

False, use Math.pow(x,y)

Back

Which of the following is NOT a constant declared in Java API

Front

conversions.KILOMETERS_PER_mile Math.PI Math.E Integer.MAX_VALUE

Back

The string class is a part of what package?

Front

java.lang

Back

A widening conversion converts a primitive value to a larger primitive type

Front

True

Back

A runtime error occurs when a printf field width is insufficient to display a value.

Front

true

Back

A static import let's you refer to a static method without using its class name.

Front

true

Back

The classes of the java.util package are automatically imported into every Java program.

Front

false, only package automatically imported is java.lang

Back

Constants make maintenance tasks easier

Front

true

Back

By default, what characters are used to separate input tokens when reading input using a Scanner object?

Front

spaces, tabs, and newline characters

Back

Suppose the integer variable hours contains a value that represents a number of hours. Which of the following expressions will compute how many 24-hour periods are represented by that value, without worrying about any leftover hours.

Front

hours / 24

Back

Section 3

(50 cards)

The relational operators can be used to put String objects in alphabetical order.

Front

False

Back

The not operator (!) requires two operands.

Front

false, it only has one operand

Back

If a String variable called pioneer contains the characters "Grace Murray Hopper", what is the result of the expression pioneer.length()?

Front

19

Back

If A is true and B is false, then the expression A || B is true. True

Front

true, only one has to be true

Back

What is a program's flow of control?

Front

The order in which statements are executed

Back

The arithmetic operators have a lower precedence than the relational operators.

Front

false, other way around

Back

What is the default flow of control through a method?

Front

linear

Back

What is ASCII

Front

A subset of Unicode containing primarily English characters and basic symbols

Back

After the following line of code is executed, the value stored in the variable num will be in what range? num = (int) (Math.random() * 25);

Front

0 to 24

Back

What is the output of the following statement? System.out.println("He said \"Avada Kedavra\"");

Front

He said "Avada Kedavra"

Back

If a String variable called address contains the characters "123 Main Street", what is the result of the expression address.indexOf('3')?

Front

2, since string indexes start at 0, the character "3" is at index 2

Back

The java keyword new is

Front

an operator

Back

What is the role of the seed value of a random number generator?

Front

It is a number that is the basis of the calculated pseudorandom numbers

Back

The condition of an if statement must be a boolean expression

Front

true

Back

What will happen if the variable total has the value 5 when the following code is executed? if (total > 8) System.out.println("collywobbles");

Front

The word is not printed and processing continues

Back

Given the following declaration, which expression would produce the substring "ledge"? String words = "Knowledge is power.";

Front

words.substring(4,9);

Back

Which statement would produce the following output? Eeny Meeny Miny Moe

Front


is new line \t is tab

Back

A String method can be called through a string literal.

Front

true

Back

If the type of the expression in a return statement does not match the return type of the method, the compiler will issue an error message.

Front

true, they must match

Back

What output would be produced when the following code is executed? String state = "Mississippi"; System.out.println(state.replace("is", "was"));

Front

Mwasswassippi

Back

The result of a relational operator can be assigned to a boolean variable.

Front

true

Back

If gen refers to a Random object, the expression gen.nextInt(30) will produce a value in what range?

Front

0 to 29 A call to nextInt(N) returns a value in the range 0 to N-1

Back

What do the characters in a Unicode escape sequence represent?

Front

the hexadecimal code for a particular unicode character

Back

If gen refers to a Random object, which of the following expressions would produce a value in the range 1 to 10?

Front

gen.nextInt(10) + 1

Back

If a String variable called greeting contains the characters "hello", what does the expression greeting.toUpperCase() accomplish?

Front

Returns a new string containing the characters "HELLO"

Back

What operator is used to perform string concatenation in Java?

Front

+

Back

The unicode character set represents over 65,000 characters

Front

true

Back

A String object cannot be created using the new operator.

Front

false, you can use the new operator, but often a string literal will suffice

Back

Java uses the Unicode character set to represent characters.

Front

true

Back

If A is false, then the B operand in the expression A || B is not evaluated.

Front

false, if b is true than it is true

Back

A method declaration includes parentheses after the method name, even if the method takes no parameters. True

Front

true, that is how the compiler knows you are declaring a method

Back

Which is not valid?

Front

""
"" This is not valid because the double quotes inside the string literal must be represented using escape sequences

Back

What technique is used to put Unicode characters and strings in order?

Front

lexicographic ordering

Back

If gen refers to a Random object, the expression gen.nextInt(12) - 2 will produce a value in what range?

Front

-2 to 9

Back

Which statement would produce the following output? "Oom Pah Pah Oom Pah Pah," that's how it goes.

Front

use \" to print quotation marks

Back

Attempting to follow a null reference will cause an exception to be thrown.

Front

true

Back

When a method is called, the type and value of each argument are included in parentheses.

Front

false, the types of arguments are only included in the method declaration

Back

A constructor of a class has the same name as the class

Front

true

Back

If A and B are both false, then the expression A && B is false. True

Front

true, both have to be true

Back

A character set is

Front

the list of all characters used by a programming language

Back

An if statement affects a program's flow of control.

Front

true, the condition determines which statement is executed next

Back

The exclusive or operator (^) produces results that are opposite to the regular or operator (||).

Front

false, the only difference is when both operands are true

Back

An assignment statement affects a program's flow of control.

Front

false, an assignment statement does not determine which statement is executed next

Back

The return type of a method must either be a Java primitive type or void.

Front

False, a method could also return an object

Back

An object must be created when its object reference variable is declared.

Front

false, those can be separate activities

Back

The less than operator (<) should not be used to compare floating-point values.

Front

false,

Back

A variable can be declared inside the body of a method.

Front

true, such variables are called local data

Back

A method that has a return type of void does not have to have a return statement.

Front

true

Back

It is usually not a good idea to explicitly return a true or false literal value in a method that returns a boolean value.

Front

true, it is better to return the boolean expression

Back

If gen refers to a Random object, the expression gen.nextInt(10) + 5 will produce a value in what range?

Front

5 to 14 If they initial range is 0 to 9, then it is shifted to 5 to 14

Back

Section 4

(13 cards)

In some cases, a sentinel value can be used to signal the end of input.

Front

true

Back

What causes an infinite loop?

Front

a loop condition that is never false

Back

A for loop could always be written as an equivalent while loop.

Front

true

Back

After a method finishes executing, control returns to the place the method was called.

Front

true

Back

Using a while loop to check each input value for correctness is a form of input validation.

Front

true

Back

The unicode character set represents over 65,000 characters

Front

true

Back

The control variable must be declared in the for loop header.

Front

false, it could be declared previously

Back

A while loop affects a program's flow of control.

Front

true

Back

Which of the following is NOT a repetition statement in Java?

Front

if statement

Back

The increment section of the for loop header always adds 1 to the loop control variable.

Front

false, you can update variable to anything

Back

Going from left to right, what are the three sections of a for loop header?

Front

initialization, condition, increment

Back

The body of a while loop may never execute.

Front

true

Back

There is no way to stop an infinite loop

Front

false, ctrl-c

Back