PRS Test

Ace your homework & exams now with Quizwiz!

The following method: public int getSize(){ return size; } is a(n) ________________. 1. accessor 2. mutator 3. constructor 4. None of the above

1

What Java operator reverses the truth or falsity of a condition? & ! % -

!

Which of the following is not a Boolean operator? && ! || ++

++

Which characters mark the beginning of a multi line comment?

/*

What does the following code output? for (int n=4; n>0; n--); System.out.print(n); 1. 1234 2. 4321 3. 0 4. Nothing. Does not compile.

0

If we have Animal, Insect, Mammal, and Fish classes, which one will be the superclass? 1. Animal 2. Insect 3. Mammal 4. Fish

1

The condition in which an array does not have any unused position left to add another element is known as _____________. 1. array overflow 2. out of bounds error 3. ArrayOutOfBoundsException 4. memory overflow

1

What are the two problems of fixed-size array declarations? 1. They waste memory space and they have a limitation on the number of objects the array can process. 2. They are difficult to maintain and they are prone to OutOfBoundsExceptions. 3. They need to be constantly updated and are not usable until all space in the array is filled. 4. They use more space and they take more computing power to handle.

1

What is the relationship between a class and an object of that class? 1. A class is a kind of mold or template that dictates what objects can and cannot do. 2. An object is the same as a class. 3. A class is an instance of an object. 4. A class is like CSCE155 and an object is like a student registered in CSCE155.

1

Which is not a restriction of using a for-each loop? 1. Only update 2. Only single structure 3. Only single element 4. Only forward

1

Which of the following would be the best choice to make a class variable (as opposed to an instance variable) of the class Person? 1. averageLifeExpectancy 2. age 3. gender 4. typeOfCarDriven

1

Why are loops particularly useful for array operations? 1. Because loops easily traverse through the indexes of the array. 2. Because loops solve problems that otherwise would not be solvable without them. 3. Because loops take less time to run than conventional coding without loops. 4. Loops do not aid in the processing of arrays.

1

Given x = 10, y = 7, z = 2.5, what is the value of the following expression? x + 3 / y + z * x % 2

11.0

How many standard ASCII codes are there? 7 50 100 128

128

How would we access the 12th row of the 3rd column of the two-dimensional array, x? 1. x[12][3]; 2. x[11][2]; 3. x[3][12]; 4. x[2][11];

2

How would you define a Java array? 1. a collection of data values of different types 2. a collection of data values of the same type 3. a collection of characters that incidentally form a string 4. a collection of primitive data types

2

Java's garbage collector: 1. manages the communications between the CPU and main memory 2. searches for inaccessible objects and converts their space to "free space" 3. prevents Java programs from connecting to unsafe Web sites

2

What is the name of the class that contains the abs, min, and round methods? 1. Arithmetic 2. Math 3. Number 4. Calculate

2

Which of the following declares and creates an array of integers of size 20? 1.int[] a = int[20]; 2.int[] a = new int[20]; 3.int a = new int[19]; 4.int a[] = new int[19];

2

Which of the following is a syntactically correct Java example of accessing an element in a two-dimensional array named table? 1. table{2, 2} 2. table[2][2] 3. table[2, 2] 4. table(2, 2)

2

Which of the following is not a class-object pair? 1. Family - Adam's Family 2. Family - John Smith 3. Reality TV Show - Survivor 4. Course - CSCE155

2

Which of the following is not a valid Java identifier?

2Jim# (because of hash)

A data value can be either a _______ or a _____. (Choose the best answer.) 1. local variable, global variable 2. procedure, function 3. constant, variable 4. argument, parameter

3

A table with multiple columns can best be modeled with ____________. 1. a single array. 2. two arrays. 3. a two-dimensional array. 4. a multi-indexed array.

3

An argument is used to: 1. override the object's method definition. 2. define constants in any given class. 3. provide values in messages to specify what is to be done by an object's methods. 4. perform mathematical tasks in Java.

3

The Integer and Character classes are examples of 1. framework classes 2. language classes 3. wrapper classes 4. primitive classes

3

The practice of hiding the details from the user of what goes on inside of an Object is known as ____________. 1. polymorphism 2. inheritance 3. encapsulation 4. access modification

3

The practice of writing multiple constructors to handle different sets of inputs is known as _____________. 1. inheritance 2. polyinputting 3. overloading 4. multiplicity

3

What are the two methods in the Throwable class? 1. try and catch 2. throw and catch 3. printStackTrace and getMessage 4. exception and printStackTrace

3

What are the two most important concepts in object-oriented programming? 1. Objects and programming 2. Objects and orientation 3. Objects and classes 4. Objects and methods

3

What is meant by "returning an object" from a method? 1. It means you are returning a null value to the caller. 2. It means returning a primitive type to the caller. 3. It means returning the object's address to the caller. 4. It means returning the object's value to the caller.

3

What is the difference between programmer- defined classes and standard classes? 1. Programmer-defined classes are always written after standard classes. 2. Programmer-defined classes can be named anything the user chooses, while standard classes have strict formatting regulations. 3. Programmer-defined classes are written by the programmer, while standard classes are built into Java. 4. Programmer-defined classes are written by the programmer, while standard classes are created automatically after compilation

3

If <statement1>throws an exception, which statements will be executed? try { <statement 1> <statement 2> } catch (Exception e) { <statement 3> <statement 4> } finally { <statement 5> <statement 6> } 1. Statement 2 only 2. Statements 3 and 4 3. Statements 5 and 6 4. Statements 3, 4, 5, and 6 5. Statements 2-6 6. None, the system will crash

4

The commonly acceptable class listing convention is class <class name> { ____________________. } 1. data members methods constructor 2. constructor data members methods 3. methods data members constructor 4. data members constructor method

4

The keyword "this" is a(n) ______________. 1. Boolean expression 2. access modifier 3. variable 4. self-referencing pointer

4

Which of the following is not true about arguments and parameters? 1. Arguments are passed to a method using the pass-by-value scheme. 2. Arguments are matched to the parameters from left to right. 3. Parameters and arguments do not have to have the same name. 4. Changes made to the parameters will affect the value of corresponding arguments. 5. Local copies are created even if the parameters and arguments share the same name

4

Which of the following is not true about count- controlled and sentinel-controlled loops? 1. For loops are the natural implementation choice for count-controlled loops 2. While loops are the natural implementation choice for sentinel-controlled loops 3. If one knows exactly the number of iterations for a loop, then one should use a count-controlled loop 4. If the number of iterations for a loop depends on certain condition or event becoming true, then one should use a sentinel-controlled loop 5. A loop cannot be both count-controlled and sentinel-controlled

4

Which of the following is not true? 1. An exception represents an error condition that can occur during the normal course of program execution. 2. When an exception occurs, we say that an exception is thrown. 3. When the matching exception-handling code is executed, we say that the thrown exception is caught. 4. When an exception occurs, the normal sequence of flow continues but the exception-handling routine is also executed

4

Which of the following pairs of terms are synonyms for a subclass? 1. derived class and base class 2. ancestor and base class 3. derived class and ancestor 4. descendant and derived class

4

Which of the following shows the syntax for object creation for a defined object? 1. <object name> = new <arguments> ( <class name> ) ; 2. <class name> = new <object name> ( <arguments> ) ; 3. <object name> = <class name> <identifier> ; 4. <object name> = new <class name> ( <arguments> ) ;

4

Which of the following statements are true? I. Usually, a data member of a class is declared "private." II. Usually, a method of a class is declared "public." III. Methods that client programmers do not need to know about or do not need to use should be declared "private." IV. Sometimes, data members such as constants are declared "public" so that client programmers could access them (since constants cannot be modified). 1. I & II only 2. I, II, & III only 3. I, II, & IV only 4. I, II, III, & IV

4

Why should we not use non-integer real numbers as counters in loops? 1. they are not allowed in loops 2. they are slower and less efficient than integers 3. they use more memory 4. a slight imprecision in repeating numbers can cause the loop to repeat infinitely

4

Which of the following is syntactically incorrect? 1. Alien myAlien1, myAlien2; 2. myAlien1 = new Alien(); 3. myAlien1.run(); 4. Alien myAlien1 = new Alien(); 5. Alien myAlien2.run();

5

What does the following code output? int i=0, y=0; while (i <= 2) { i++; y += i; } System.out.print(y); 0 4 5 6

6

What does the following code output? int i=0; while (i <= 5){ i++; } System.out.print(i); 0 4 5 6

6

Given the ifstatement shown, what is outputwhen x=2, y=5, and z=3? output = 0; if ( x >= 3) output = 5; else if (y < 4 && z < 3) output = 6; else if (z >= 3) { output = 7; if (y < 4) output = 8; } 0 5 6 7 8

7

Consider the block of code below with grade = 1. What is the output of this program? switch (grade) { case 1: System.out.print("A"); case 2: System.out.print("B"); case 3: System.out.print("C"); case 4: default: break; } A ABC B No output

ABC

Common order of Software Engineering phases?

Analysis, Design, Coding, Testing, Operation (Maintenance)

What type of errors CANNOT be found through testing?

Compile-time errors

Activity in the "analysis" stage of the Software Engineering cycle

Development of a requirements specification

Which of the following is not a rule of writing well-formed ifstatements? - Minimize the number of nestings - Don't include too many ANDs or ORs - Don't include multiple statements within an if or else block - Read code over after it is completed.

Don't include multiple statements within an if or else block

Considering the following code: int x, y; x and y are objects. T/F?

False

T/F: An array is an indexed collection of data values of mixed types.

False

T/F: Class methods and class constants are referred to in the same manner, as illustrated below. <class name>.<method name> <class name>.<class constant>

False

T/F: Constructor methods never accept arguments.

False

T/F: It's legal to store ints and doubles in a single standard array

False

T/F: Objects in Java are restricted to responding to message senders and cannot return values to the message sender.

False

T/F: Relational and equality operators have higher precedence than the arithmetic operators.

False

T/F: The JCF is the set of all of Java's standard libraries.

False

T/F: The length property field refers to the number of non-empty cells in any array.

False

T/F: The value of an array's length equals the value of the array's largest acceptable index.

False

T/F: To avoid runtime errors, you must always specify the size of the ArrayList when you declare and create it.

False

T/F: You must use a for-each loop, and not a traditional forloop, whenever you need to iterate through an ArrayList.

False

The expression: (int) x % 3; is an example of an implicit typecast T/F?

False

Tracing is used to 1) obtain an intimate understanding of what the algorithm does and 2) debug programs that have syntax errors. T/F

False

One can convert an integer to a string with a simple typecast such as: ... (String) x ... where x is an int data type T/F?

Flase

What are braces {} used for

Grouping things together

Which of the following is a method that might possibly encounter the NumberFormatException? 1. String.concat 2. Math.min 3. System.out.println 4. Long.parseLong

Long.parseLong

What follows standard java to handle trig functions: Sine Math Scanner Integer

Math

the work println is a

Method

Whats NOT a Java IDE

Microsoft Visual Studio .NET

What is the value of y after executing the following lines of code? int x = 10; int y = 7; double z = 2.5; x = z; y = x;

Nothing, it will not compile

What are the three types of flow statement groupings?

Sequential, Branching, & Looping

What is a compiler?

Software tool which translates source code into language

Consider the following fragment of code: int x = 10, y = 20; String b = "Sum is " + x + y; System.out.println(b); What will be the output of this program? Sum is 30 Sum is 10 20 Sum is 1020 The program will not compile because the code is invalid.

Sum is 1020

We are writing a program to model the behavior of a car. Which of the following is a valid candidate to be represented with a constant as opposed to a variable? The level of fuel in the gas tank The maximum speed that the speedometer can read The number represented by the car's odometer The number of miles to the next oil change

The max speed that the speedometer can read

A class name B$$$ follows Java standard naming convention T/F

True

Looping is appropriate whenever the next thing done is something previously done. T/F

True

T/F: A string can be represented as an array of characters.

True

T/F: A variable-size array takes more work to maintain than a fixed-size array.

True

T/F: At most one catch block is executed, and superfluous catch blocks will be ignored.

True

T/F: Braces are necessary if there are multiple statements in an ifor elseblock.

True

T/F: String objects are immutable, which means once they are created, they cannot be changed.

True

Three tools are necessary to program in Java: text editor, a compiler, and a run-time engine. T/F

True

within an assignment statement, the value that was stored in the variable is overwritten by a new value T/F

True

which of the following is NOT true about "main" or "application" class?

a "main" class does not have a class definition

Which is an equivalent logical expression to the following logical expression: !(!a || !b) !a && !b a || b a && b !a || !b

a && b

what is not a java identifier

black&white (because of &)

We use the __________ method of the String class to access individual characters within the string. charAt size indexOf char

charAt

The practice of placing output statements in the default case of a switch statement when it is not necessary is known as _________: inefficiency modular testing integrative testing defensive programming

defensive programming

Which of the following describes the mechanism that is used to improve a program's robustness by handling erroneous input, for example? 1. modular testing 2. integrative testing 3. assertions 4. exception handling

exception handling

which of the following variable declarations would generate a compile-time error? int i, j, k; int float x, y; float m = 22.33; long f = 2300, g = 12395;

int float x, y;

What is wrong with the following code? int product = 0; int count = 0; while (product<2500){ product *= 5; count++; } 1. the syntax of the while statement is invalid. 2. the operator, *=, does not exist. 3. it has an infinite loop 4. the count variable is initialized incorrectly

it has an infinite loop

every java app must have a(n) ___ method

main

The reading of a value before the conditional inside a loop tests that value is known as a(n) _____________. - priming read - assumed input - anticipated read - blind conditional

priming read

Flowchart symbol for input is a(n)

rectangle

What does the following code fragment print? String name = "Johnson"; System.out.print(name.charAt(4)); J h n s o

s

A sentinel value is used to: - specify the first value printed - print an error message - signal the end of the input - store info in memory

signal the end of the input

What are the three type of Java comments?

single line, comment markers, Javadoc comments

Which of the following would return the last character of the String x? x.charAt (0); x.charAt (last); x.charAt (length(x)); x.charAt(x.length( ) -1); x.charAt(x.length( ) );

x.charAt(x.length( ) -1);


Related study sets

BASIC VEHICLE TECHNOLOGIES 2: ENGINES

View Set

ATI Nurse Logic: Priority Setting Frameworks

View Set

Microeconomics Chapter 4 Test Adaptive Questions

View Set

Internal Controls Midterm (Ch. 5, 6, 13)

View Set

Early Civ of China: Confucianism, Taoism, and Legalism

View Set

Session #74-75 (The Secretory Pathway: Protein Sorting, Processing and Transport to Target Membranes)

View Set