Question: 1. To use a predefined method you must know the code in the body of the method. a) TRUE b)FALSE 2. The value returned by

1. To use a predefined method you must know the code in the body of the method.

a) TRUE

b)FALSE

2. The value returned by a value-returning method can be saved for further calculation in the program.

True

False

3.

A formal parameter is a variable declared in the method heading (ie. it's signature).

True

False

4.

A local identifier is an identifier that is declared within a method or block and that is visible only within that method or block.

True

False

5.

No two methods in the same class can have the same name.

True

False

6.

Void methods have no return type.

True

False

7.

The return statement must be the last line of the method.

True

False

8.

When a program executes, the first statement to execute is always the first statement in the main method.

True

False

9.

Given the method heading

public static String exampleMethod(int n, char ch)

what is the return type of the value returned?

int

char

String

Nothing will be returned

10.

The method toString() is used to convert an object to a String object.

True

False

11.

Consider the following method.

public static int minimum(int x, int y)

{

int smaller;

if (x < y)

smaller = x;

else

smaller = y;

return smaller;

}

Which of the following is a valid java statement which calls this method?

minimum(5, 4);

minimum(int 5, int 4);

minimum(int x, int y);

public static int minimum(5, 4);

12.

Consider the following method.

public static int minimum(int x, int y)

{

int smaller;

if (x < y)

smaller = x;

else

smaller = y;

return smaller;

}

What is the value of s after the following statement executes?

int s = minimum(5, minimum(3, 7));

3

5

7

None of these

13.

Given the method heading

int larger(int x, int y)

which of the following does NOT demonstrate method overloading?

int larger(int x, int y, int z)

int larger(char x)

int max(int x, int y)

double larger(double x, double y)

14.

How many constructors can a class have?

0

1

2

Any number

15.

Which of the following is NOT an actual parameter?

Expressions used in a method call

Variables used in a method call

Variables defined in a method heading

Constant values used in a method call

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!