Java test 2

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

Which of the following lines is not a Java comment?

-- comments

How many unique items can be represented by 10 bits?

2^10

One byte has ________ bits

8

Which of the following statements is true?

A class can have more than one constructor

________ is invoked to create an object.

A constructor

What reserved word can be used to end execution of a loop?

Break

If you want to be able to compare two objects, then what interface should you implement?

Comparable

Variables that are shared by every instances of a class are ________________ variables

static

A private method is referred to as a(n) ________ method, while a public method is referred to as a(n) ________ method.

support, service

Which of the following lines of code cannot be placed in a static method?

this.count++;

Suppose that an instance variable called length is in the Race class. How can the variable be accessed from within the class?

this.length

The words ________________________ are reserved in Java as Boolean literals:

true, false

Given the declaration Account x = new Account (), which of the following statement is most accurate. a) x contains an int value.

x contains a reference to a Account object.

Java is interpreted, but not compiled

False

The default layout out of a contentPane in a JFrame is __________.

FlowLayout

The expression "Java " + 1 + 2 + 3 evaluates to ________.

Java123

Which of the following is a logical operator (i.e. one that must have boolean operands)?

None of the above

Which of the following items is most likely to be provided by the client rather than the developer for a software project?

Requirements

Objects of which of the following types are iterators?

Scanner

Java was developed by ____________.

Sun Microsystems

Which of the following statements is correct to display Welcome to Java on the console?

System.out.println ("Welcome to Java");

Which of the following is executed first when you run your Java application?

The main method of your class

Suppose that a method has a single formal parameter of type String and that the method is invoked with a String variable. Which of the following is true about the actual and formal parameter?

They reference the same object

A ________ class diagram shows the relationships between classes in a project.

UML

Select the TRUE statement from the choices below, regarding the difference between LAN and WAN network?

WAN connects two or more LANs.

Which of the following provides the object equivalent of a primitive type?

Wrapper class

If a program compiles fine, but it produces incorrect result, then the program suffers __________.

a logical error

What is the representation of the third element in an array called a?

a[2]

Which of the following represents the correct increasing range of values for integer types, from left to right?

byte short int long

Which of the following types can be used as an initial expression in a switch statement?

char

Static methods are also called ________ methods

class

The reserved word __________ is required to declare a class.

class

In order to implement Comparable in a class, what method(s) must be defined in that class?

compareTo

Typing a { when you should have typed a ( is a/an _____________________ error.

compile-time

Aggregation is

described as a has-a relationship

Which of the following lines contains a narrowing conversion?

double value3 = (int) 3.5;

If an array is sent as a parameter to a method and modified within that method, the modifications to the array will be lost once the invoked method has ended execution.

false

Java arrays can store primitive types and Strings, but cannot store any other type of Object other than Strings.

false

Constant class fields are declared with the following two reserved words:

final, static

Suppose that the array groupList has a value of null. Which of the following will generate a run- time error?

if (groupList.length > 0 && groupList != null) { }

Which of the following is a correct way to declare variables?

int length, width;

If a method does not have a return statement, then

it must be a void return type

When a class implements an interface, what must it do?

it must declare and provide a method body for each method in the interface.

Multiplying two numbers when you meant to add them is a/an __________________ error.

logical

Which of the following is not a reserved word?

main

A(n) ________ method changes the ________ of the object

mutator, state

Which of the following (if any) is not a valid variable name?

new

The relationship between a class and an object is best described as

objects are instances of classes

Parameters to methods always appear within __________.

parentheses

Well encapsulated classes have _______________ variables and ________________ methods.

private, public

Which of the following is an INVALID identifier?

book-mark

Which of the following is an infinite loop?

for(inti=3;i>2;i++){}

Two methods can have the same name in a class if they have different _________.

formal parameters

If the Trajectory class uses the static methods found in the Math class, then what is the relationship between Trajectory and Math in a UML class diagram?

general dependency

Method decomposition ________ the number of methods in a class.

increases

The main method cannot directly access ________ variables of the class containing main

instance

When an object is created, space is reserved in memory for that object's _________.

instance data

A(n) ________ variable cannot be accessed by a ________ method in the same class.

instance, static

The words required at the start of every "main" method definition are:

public static void

An aggregate object always contains which of the following:

reference variables


Conjuntos de estudio relacionados

Seminar Comprehensive Exam Study Guide, Part 1 (of 2)

View Set

P.E. B test 5- Time Management 3

View Set

Chapter 10: Musculoskeletal System- Skeletal

View Set

Public speaking - Exam Study guide

View Set