Java 1 Multiple choice

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

This is automatically provided for a class if you do not write one yourself. a. accessor method b. default instance c. default constructor d. variable declaration

c. default constructor

The key word is used to declare a named constant. a. constant b. namedConstant c. final d. concrete

c. final

This type of loop has no way of ending and repeats until the program is interrupted. a. indeterminate b. interminable c. infinite d. timeless

c. infinite

These arc words that have a special meaning in the programming language. a. punctuation b. programmer-defined names c. key words d. operators

c. key words

Every complete statement ends with a _. a. period b. parenthesis c. semicolon d. ending brace

c. semicolon

This type of method cannot access any non-static member variables in its own class. a. instance b. void c. static d. non-static

c. static

The following is an explicit call to the superclass's default constructor. a. default( ); b. class( ); c. super( ); d. base( );

c. super( );

The conditional operator takes this many operands. a. one b. two c. three d. four

c. three

To open a file for reading, you use the following classes. a. File and Writer b. File and Output c. File and Input d. File and Scanner

d. File and Scanner

This class allows you to use the print and println methods to write data to a file. a. File b. FileReader C. OutputFile d. PrintWriter

d. PrintWriter

Assuming the following declaration exists: enum Seasons { SPRING, WINTER, SUMMER, FALL } what is the fully qualified name of the FALL constant? a. FALL b. enum.FALL C. FALL.Seasons d. Seasons.FALL

d. Seasons.FALL

This key word indicates that a class inherits from another class. a. derived b. specialized c. based d. extends

d. extends

An object is a(n)_. a. blueprint b. primitive data type c. variable d. instance of a class

d. instance of a class

This is a method that stores a value in a field or in some other way changes the value of a field. a. accessor b. constructor c. void d. mutator

d. mutator

True or False: When passing multiple arguments to a method, the order in which the arguments are passed is not important.

False

True or False: When you write a constructor for a class, it still has the default constructor that Java automatically provides.

False

This is the typical number of comparisons performed by the sequential search on an array of N elements (assuming the search values are consistently found), a. 2N b. N c. N2 d. N/2

N/2

True or False: A Variable must be declared before it can be used

True

True or False: A conditionally executed statement should be indented one level from the if clause.

True

True or False: An ArrayList automatically expands in size to accommodate the items stored in it.

True

True or False: Comments that begin with // can be processed by javadoc.

True

True or False: Enumerated data types are actually special types of classes.

True

True or False: In a nested loop, the inner loop goes through all of its iterations for every iteration of the outer loop.

True

True or False: The Java compiler does not display an error message when it processes a statement that uses an invalid subscript

True

True or False: The new operator creates an instance of a class.

True

True or False: The scope of a variable is limited to the block in which it is defined.

True

True or False: The subscript of the last element in a single-dimensional array is one less than the total number of elements in the array.

True

True or False: The while loop is a pretest loop.

True

True or False: When an if statement is nested in the if clause of another statement, the only time the inner if statement is executed is when the boolean expression of the outer if statement is true.

True

True or False: When an object, such as a string , is passed as an argument, it is actually a reference to the object that is passed.

True

True or False: When passing an argument to a method, Java will automatically perform a widening conversion (convert the argument to a higher-ranking data type), if necessary.

True

Which of the following arc not valid p r i n t l n statements? (Indicate all that apply.] a. System.out.println * "Hello World"; b. System.out.println("Have a nice day"); C. out.System.println{value); d. prntln. out (Programming is great fun);

a, c, d

When determining whether a number is inside a range, it's best to use this operator. a. && b. ! c II d. ? :

a. &&

These characters mark the beginning of a single-line comment. a. / / b. /* i . */ d. /**

a. //

You can use this class to display dialog boxes a. JOptionPane b. ButferedReader c. InputStreamReader d. DialogBox

a. JOptionPane

All classes directly or indirectly inherit from this class. a. Object b. Super C. Root d. Java

a. Object

Each byte is assigned a unique a. address b. CPU C. bit d. variable

a. address

A group of statements, such as the contents of a class or a method, are enclosed in _. a. braces{} b. parentheses () c. brackets [ ] d. any of these will do

a. braces {}

This type of operator lets you manually covert a value, even if it means that a narrowing conversion will take place. a. cast b. binary C. uploading d. dot

a. cast

This is a collection of programming statements that specify the fields and methods that a particular type of object may have. a. class b. method c. parameter d. instance

a. class

The body of a method is enclosed in_. a. curly braces { } b. square brackets [ ] c. parentheses ( ) d. quotation marks " "

a. curly braces { }

This is a boolean variable that signals when some condition exists in the program. a. flag b. signal C. sentinel d. siren

a. flag

This expression is executed by the for loop only once, regardless of the number of iterations. a. initialization expression b. test expression C. update expression d. pre-increment expression

a. initialization expression

This is a variable that controls the number of iterations performed by a loop. a. loop Control variable b. accumulator c. iteration register variable d. repetition meter

a. loop Control variable

This is an if statement that appears inside another if statement. a. nested if statement b. tiered if statement c. dislodged if statement d. structured if statement

a. nested if statement

A method in a subclass having the same name as a method in the superclass but a different signature is an example of a. overloading b. overriding c. composition d. an error

a. overloading

These characters serve specific purposes, such as marking the beginning or ending of a statement, or separating items in a list. a. punctuation b. programmer-defined names c. key words d. operators

a. punctuation

>, <, and = are_. a. relational operators b. logical operators c. conditional operators d. ternary operators

a. relational operators

This is a special value that signals when there are no more items from a list of items to be processed. This value cannot be mistaken as an item from the list. a. sentinel b. flag c. signal d. accumulator

a. sentinel

To determine the number of items stored in an ArrayList object, you use this method, a. size b. capacity C items d. length

a. size

This key word refers to an object's superclass. a. super b. base c. superclass d. this

a. super

These are rules that must be followed when writing a program a. syntax b. punctuation C. key words d. operators

a. syntax

It you write tins method for a class, Java will automatically call it any time you concatenate an object of the class with a string. a. toString b. plusString C. strlngConvert d. concatString

a. toString

The first subscript in an array is always a. 1 b. 0 c. -1 d. 1 less than the number of elements

b. 0

This javadoc tag is used to document a parameter variable. a. @parameter b. @param C. @paramvar d. @arg

b. @param

This part of the computer fetches instructions, carries out the operations commanded by the instructions, and produces some outcome or resultant information. a. memory b. CPU c. secondary storage d. input device

b. CPU

CRC stands for a. Class, Return value, Composition b. Class, Responsibilities, Collaborations c. Class, Responsibilities, Composition d. Compare, Return, Continue

b. Class, Responsibilities, Collaborations

If you were to look at a machine language program, you would see_. a. Java source code b. a stream of binary numbers c. English words d. circuits

b. a stream of binary numbers

A value that is passed into a method when it is called is known as a(n)_. a. parameter b. argument c. signal d. return value

b. argument

The process of matching a method call with the correct method is known as-. a. matching b. binding c. linking d. connecting

b. binding

The Java compiler generates_. a, machine code b. byte code C. source code d. HTML

b. byte code

This is a method that is automatically called when an instance of a class is created. a. accessor b. constructor C. void d. mutator

b. constructor

The if statement is an example of a_. a. sequence structure b. decision structure c. pathway structure d. class structure

b. decision structure

This key word causes an object to be created in memory. a. create b. new c. object d. construct

b. new

What Scanner class method would you use to read a string as input? a. nextString b. nextLine c. readString d. getLine

b. nextLine

The do-while loop is this type of loop. a. pretest b. posttest c. prefix d. postfix

b. posttest

This search algorithm steps through an array, comparing each item with the search value. value. a. binary search b. sequential search c. selection search d. iterative search

b. sequential search

In an array declaration, this indicates the number of elements that the array will have. a. subscript b. size declarator c. element sum d. reference variable

b. size declarator

In an inheritance relationship, this is the general class. t . subclass b. superclass c. slave class d. child class

b. superclass

This is the name of a reference variable that is always available to an instance method and refers to the object that is calling the method. a. callingObject b. this C. me d. instance

b. this

True or False: An array's size declarator can be a negative integer expression.

False

True or False: If one of an operator's operands is a double, and the other operand is an int, Java will automatically convert the value of the double to an int

False

True or False: It is possible for one method to access a local variable that is declared in another method.

False

True or False: One limitation of the for loop is that only one variable may be initialized in the initialization expression.

False

This type of method does not return a a. null b. void C. empty d. anonymous

b. void

True or False: The first size declarator in the declaration of a two-dimensional array represents the number of columns. The second size declarator represents the number of rows.

False

True or False: The for loop is a posttest loop,

False

True or False: To find the classes needed for an object-oriented application, you identify all of the verbs in a description of the problem domain.

False

This javadoc tag is used to document a methods return value. a. @Methodreturn b. @ret C. @return d. @returnval

C. @return

You can use this method to display formatted output in a console window. a. Format.out.println b. Console.format C. System.out.printf d. System.out.formatted

C. System.out.printf

Fields in an interface are_. a. final b. static C. both final and static d. not allowed

C. both final and static

The Java Virtual Machine periodically performs this process, which automatically removes unreferenced objects from memory. a. memory cleansing b. memory deallocation C. garbage collection d. object expungement

C. garbage collection

This operator can be used to determine whether a reference variable references an object of a particular class. a. isclass b. typeof C. instanceof d. isinatance

C. instanceof

This is an empty statement that does nothing. a. missing statement b. virtual statement C. null statement d. conditional statement

C. null statement

In the expression number++, the • ++operator is in what mode? a. prefix b. pretest C. postfix d. posttcst

C. postfix

Array bounds checking happens_. a. when the program is compiled b. when the program is saved C. when the program runs d. when the program is loaded into memory

C. when the program runs

True or False: A method cannot return a reference to an object.

False

True or False: A parameter variable's scope is the entire program that contains the method in which the parameter is declared.

False

True or False: All static member variables are initialized to -1 by default.

False


Ensembles d'études connexes

Chapter 2 bio- elements atoms and bonds

View Set

Chapter 3: Basic Application Software

View Set

Exam #2 Multiple Choice Questions

View Set

Performance and Breach: Implied Warranties of Merchantability and Fitness for a Particular Purpose

View Set

pelvic pain, normal and abnormal uterine bleeding

View Set

Business Analytics I (BUAL 2600) Exam 2

View Set

EXAM 2 System Analysis and Design

View Set