• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/77

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

77 Cards in this Set

  • Front
  • Back


________ is a graphical language that allows people who design software systems to use an industry standard notation to represent them.


The Unified Modeling Language

What is the difference between a float and a double?


Double variables store numbers with larger magnitude and finer detail.

Which command executes the Java class file Welcome.class?

java Welcome


Which of the following is not one of the six logical units of a computer?

Printer

Which of the following is not a control structure:


Declaration structure.

All import declarations must be placed


before the class declaration.

Which of the following is not a Java primitive type?

real

Every Java application is composed of at least one:

public class declaration


Which of the following statements is false?

Information in the memory unit is persistent—it is retained when the computer's power is turned off.

What is output by the following Java code segment?
int temp = 180;

while ( temp != 80 )
{
if ( temp > 90 )
{
System.out.print( "This porridge is too hot! " );

// cool down
temp = temp – ( temp > 150 ? 100 : 20 );
} // end if
else
{
if ( temp < 70 )
{
System.out.print(
"This porridge is too cold! ");

// warm up
temp = temp + (temp < 50 ? 30 : 20);
} // end if
} // end else
} // end while

if ( temp == 80 )
System.out.println( "This porridge is just right!" );

This porridge is too hot! This porridge is just right!


Which command compiles the Java source code file Welcome.java?

javac Welcome.java

Which class provides prebuilt dialog boxes that enable programs to display windows containing messages (such windows are called message dialogs)?

JOptionPane

Attributes of a class are also known as:

Fields

Which of the following is not one of the three general types of computer languages?

Spoken languages.

What is the default value of a reference?

null

What does the expression x %= 10 do?

Divides x by 10 and stores the remainder in x.

Which of the following does not contain a syntax error?

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

Which statement is true?

Syntax errors are caught by the compiler. Logic errors have effects at execution time.

What is the result value of c at the end of the following code segment?
int c = 8;
c++;
++c;
c %= 5;

0

What is output by the following Java code segment?
int temp = 180;

if ( temp > 90 )
{
System.out.println( "This porridge is too hot." );

// cool down
temp = temp – ( temp > 150 ? 100 : 20 );
} // end if
else
{
if ( temp < 70 )
{
System.out.println("This porridge is too cold.");

// warm up
temp = temp + (temp < 50 ? 30 : 20);
} // end if
} // end else

if ( temp == 80 )
System.out.println( "This porridge is just right!" );


None of the above.

Which of the following statements about the break statement is false?

The break statement, when executed in a while, for or do…while, skips the remaining statements in the loop body and proceeds with the next iteration of the loop.

Consider the following two Java code segments:

Segment 1

int i = 0;
while ( i < 20 )
{
i++;
System.out.println( i );
}

Segment 2

for ( int i = 0; i <= 20; i++ )
{
System.out.println( i );
}

Both (a) and (b) are true.

Which of the following will count down from 10 to 1 correctly?

for ( int j = 10; j >= 1; j-- )

Which of the following statements about the continue statement is true?


A continue statement proceeds with the next iteration of the immediately enclosing while, for, do…while statement.

Which of the following statements about a do…while repetition statement is true?


The body of a do…while loop is always executed at least once.

To exit out of a loop completely, and resume the flow of control at the next line in the method, use _______.

A break statement

Consider the code segment below.

if ( gender == 1 )
{
if ( age >= 65 )
++seniorFemales;
} // end if

This segment is equivalent to which of the following?


if ( gender == 1 && age >= 65 )
++seniorFemales;

For the code segment below:

switch( q )
{
case 1:
System.out.println( "apple" );
break;
case 2:
System.out.println( "orange" );
break;
case 3:
System.out.println( "banana" );
break;
case 4:
System.out.println( "pear" );
case 5:
System.out.println( "grapes" );
default:
System.out.println( "kiwi" );
} // end switch

Which of the following values for q will result in kiwi being included in the output?

Anything greater than or equal to 4.

Suppose variable gender is MALE and age equals 60, how is the expression
( gender == FEMALE ) && ( age >= 65 )
evaluated?

The condition ( gender == FEMALE ) is evaluated first and the evaluation stops immediately.

The control variable of a counter-controlled loop should be declared as ________to prevent errors.


int


Which statement creates a random value from the sequence 2, 5, 8, 11 and 14. Suppose randomNumbers is a Random object.

2 + 3 * randomNumbers.nextInt( 5 );

In a class containing methods with the same name, the methods are distinguished by:

(a) and (b).


Number of arguments.


Types of arguments.


Suppose method1 is declared as

void method1 ( int a, float b )

void method1 ( float a, int b )

Declaring main as ________ allows the JVM to invoke main without creating an instance of the class.

static.

To declare a method as static, place the keyword static before ________ in the method’s declaration.


the return type.

A well-designed method

performs a single, well-defined task

An overloaded method is one that

has the same name as another method, but different parameters (by number, types or order of the types).

Consider the following Java statements:

int x = 9;
double y = 5.3;
result = calculateValue( x, y );


x and y are parameters.

Which statement is not true.

The Java API consists of import declarations.

Stacks are known as ________ data structures.

LIFO

A programmer must do the following before using an array:


declare then create the array.


Which statement correctly passes the array items to method takeArray? Array items contains 10 elements.


takeArray( items )

What do the following statements do?

double[] array;
array = new double[ 14 ];

Create a double array containing 14 elements

In this question, assume a class, Book, has been defined. Which set of statements creates an array of Book objects?

Book[] books;
books = new Book[ numberElements ];

Which method call converts the value in variable stringVariable to an integer?


Integer.parseInt( stringVariable ).

Consider the array:

s[ 0 ] = 7
s[ 1 ] = 0
s[ 2 ] = -12
s[ 3 ] = 9
s[ 4 ] = 10
s[ 5 ] = 3
s[ 6 ] = 6

The value of s[ s[ 6 ] - s[ 5 ] ] is:

9


Arrays are:

fixed-length entities.

Attempting to access an array element out of the bounds of an array, causes a(n)


ArrayIndexOutOfBoundsException.

Consider the program below:

public class Test
{
public static void main( String[] args )
{
int[] a;
a = new int[ 10 ];

for ( int i = 0; i < a.length; i++ )
a[ i ] = i + 2;
int result = 0;
for ( int i = 0; i < a.length; i++ )
result += a[ i ];
System.out.printf( "Result is: %d\n", result );
} // end main
} // end class Test

The output of this program will be:

Result is: 65.

The preferred way to traverse a two-dimensional array is to use

two nested for statements.



Which of the following should usually be private?


Variables (or fields).


Having a this reference allows:

A) a method to refer explicitly to the instance variables and other methods of the object on which the method was called
B) a method to refer implicitly to the instance variables and other methods of the object on which the method was called
C) an object to reference itself


All of the above.

A class within a package must be declared public if


It will be used by classes that are not in the same package.

The import declaration import *; ________.

causes a compilation error.


When should a program explicitly use the this reference?


Accessing a field that is shadowed by a local variable.

When no access modifier is specified for a method or variable, the method or variable:

Has package access.

Static class variables:

are shared by all objects of a class.


Which of the following is false?

Objects are marked for garbage collection by method finalize.

Instance variables declared final do not or cannot:

Be modified.


A package is:

a.A directory structure used to organize classes and interfaces.


b.A mechanism for software reuse.


c.A group of related classes and interfaces


ALL OF THE ABOVE!

Failure to prefix the superclass method name with the keyword super and a dot (.) separator when referencing the superclass’s method causes ________.

infinite recursion


An advantage of inheritance is that:

Objects of a subclass can be treated like objects of their superclass.


Superclass methods with this level of access cannot be called from subclasses.


private


Overriding a method differs from overloading a method because:

Overridden methods have the same signature.

Using the protected keyword gives a member:

package access

Which superclass members are inherited by all subclasses of that superclass?

protected instance variables and methods

Every class in Java, except ________, extends an existing class.

Object

Which of the following keywords allows a subclass to access a superclass method even when the subclass has overridden the superclass method?

super


The default implementation of method clone of Object performs a ________.

shallow copy

When a subclass constructor calls its superclass constructor, what happens if the superclass’s constructor does not assign a value to an instance variable?

The program compiles and runs because the instance variables are initialized to their default values

Which of the following is a Scanner method?

nextLine

Which of the following is not a Java keyword?

next

Which of the following is a valid fully qualified name?

java.util.Scanner


Which of the following statements is true?

Compilers translate high-level language programs into machine language programs.

A(n) ________ enables a program to read data from the user.

Scanner

Which statement is true?

Syntax errors are caught by the compiler. Logic errors have effects at execution time.

________ models software in terms similar to those that people use to describe real-world objects.

Object-oriented design