Final Java test

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

What is the value of the scores [2] [3] in the following array? int [] [] scores = { {88, 80, 79, 92}, {75, 84, 93, 80}, {98, 95, 92, 94}, {91, 84, 88, 96} };

94

If method A calls method B, and method B calls method C, and method C calls method D, when method D finishes, what happens?

Control is returned to method C

Data hiding, which means that critical data stored inside the object is protected from code outside the object, is accomplished in Java by:

Data hiding, which means that critical data stored inside the object is protected from code outside the object, is accomplished in Java by using the private access specifier on the class fields.

Each array in Java has a public field named __________ that contains the number of elements in the array.

Each array in Java has a public field named length that contains the number of elements in the array .

This refers to the combining of data and code into a single object.

Encapsulation refers to the combining of data and code into a single object.

In your textbook the general layout of a UML diagram is a box that is divided into three sections. The top section has the _______; the middle section holds _______; the bottom section holds _______.

In your textbook the general layout of a UML diagram is a box that is divided into three sections. The top section has the class name; the middle section holds attributes or fields; the bottom section holds methods.

It is a common practice to use a ________ variable as a size declarator.

It is a common practice to use a final variable as a size declarator.

It is common practice in object-oriented programming to make all of a class's:

It is common practice in object-oriented programming to make all of a class's fields private.

Java performs _______, which means that it does not allow a statement to use a subscript that is outside the range of valid subscripts for the array.

Java performs array bounds checking, which means that it does not allow a statement to use a subscript that is outside the range of valid subscripts for the array.

This indicates the number of elements, or values, the array can hold.

The array's size declarator indicates the number of elements, or values, the array can hold.

This part of a method is a collection of statements that are performed when the method is executed.

The method body of a method is a collection of statements that are performed when the method is executed.

If final int SIZE = 15 and int[ ] x = new int [size], what would be the range of subscript values that could be used with X[ ]?

The range could be 0-14.

The scope of private instance field is

The scope of private instance field is the instance methods of the same class.

You should not define a class field that is dependent upon the values of other class fields:

You should not define a class field that is dependent upon the values of other class fields in order to avoid having stale data.

What would be the result of the following code? int[] x = { 55, 33, 88, 22, 99, 11, 44, 66, 77 }; int a = 10; if(x[2] > x[5]) a = 5; else a = 8;

a = 5

What will be returned from the following method? public static double methodA ( ) { double a = 8.5 + 9.5; return a; }

18 (as an integer)

Another term for an object of a class

Another term for an object of a class is instance.

In order to do a binary search on an array

In order to do a binary search on an array the array must be first sorted in ascending order.

In the following code, System.out.println(num), is an example of ________. double num = 5.4; System.out.println(num); num = 0.0;

In the following code, System.out.println(num), is an example of a void method.

In the header, the method name is always followed by

In the header, the method name is always followed by parenthesis.

What is wrong with the following method call? displayValue (double x);

Nothing is wrong with the statement.

Which of the following is included in a method call?

Parenthesis are included in a method call.

Values sent into a method

Values sent into a method are called arguments.

When an argument is passed to a method:

When an argument is passed to a method its value is copied into the method's parameter variable.

When an object, such as a String, is passed as an argument, it is:

When an object, such as a String, is passed as an argument, it is actually a reference to the object being passed.

When you pass an argument to a method, be sure that the argument's data type is compatible with:

When you pass an argument to a method, be sure that the argument's data type is compatible with the parameter variable's data type.

For the following code, which statement is NOT true? public class Sphere { private double radius; public double x; private double y; private double z; }

z is available to code that is written outside the circle class is false

A parameter variables scope is

A parameter variables scope is the method in which the parameter is declared.

A ragged array is

A ragged array is a two-dimensional array for which the number of rows is unknown.

A special variable that holds a value passed into a method is called

A special variable that holds a value passed into a method is called a parameter.

What do you call the number that is listed as an index to pinpoint a specific element within an array?

A subscript is the number that is listed as an index to pinpoint a specific element within an array.

Which of the following is NOT part of a method call? Return type, parenthesis or method name

All are part of a method call.

Given the following code, what will be the value of finalAmount when it is displayed? public class Order { private int orderNum; private double orderAmount; private double orderDiscount; public Order(int orderNumber, double orderAmt, { double orderDisc) { orderNum = orderNumber; orderAmount = orderAmt; orderDiscount = orderDisc; } public double finalOrderTotal() { return orderAmount - orderAmount * orderDiscount; } } public class CustomerOrder { public static void main(String[] args) { Order order; int orderNumber = 1234; double orderAmt = 580.00; double orderDisc = .1; order = new Order(orderNumber, orderAmt, orderDisc); double finalAmount = order.finalOrderTotal(); System.out.println("Final order amount = $" + } } finalAmount); } }

528

This type of method performs a task and sends a value back to the code that called it.

This value-returning method performs a task and sends a value back to the code that called it.

Which of the following statements will create a reference, str, to the String, "Hello, World"?

String str = "Hello, World";

Subscript numbering always starts with what value?

Subscript numbering always starts with zero.

A class specifies the ______ and ______ that a particular type of object has.

A class specifies the fields and methods that a particular type of object has.

A constructor

A constructor has the same name as the class.

Two or more methods in a class may have the same name as long as

Two or more methods in a class may have the same name as long as they have different parameter lists.

Which of the following would be a valid method call for the following method? public static void showProduct (int num1, double num2) { int product; product = num1 * (int)num2; System.out.println("The product is " + product); }

showProduct (10, 4.5) would be a valid method call for the following method.


Ensembles d'études connexes

SENTENCES : Fragments, identifying

View Set

college personal finance semester test

View Set

Chapter 4, 5 & 6 Nutrition- Kelly Owen

View Set

4.5 Maritime Empires Maintained and Developed

View Set

Choisissez (entourez) la bonne réponse

View Set

Mengenal Teks Eksplanasi - BI/G8

View Set