wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Comprog - (Predefined Methods) November 8, 2022

Total questions: 27

Worksheet time: 14mins

Name
Class
Date
1.

Methods that are already written and provided by Java.

a)

Predefined Methods

b)

User-defined Methods

c)

Prewritten Methods

d)

Preprogrammed methods

2.

Which of the following is NOT true about methods?

a)

They are also called modules

b)

It is used to divide complicated programs into manageable pieces

c)

It enhances program's readability

d)

They are ideal for shorter programs.

3.

Predefined methods in Java are organized as a collection of classes known as ________.

a)

Method libraries

b)

Class libraries

c)

Package Libraries

d)

Module

4.

What package contains the math class?

a)

java.util

b)

java.io

c)

java.lang

d)

java.sql

5.

It is the data type of the value returned by the method.

a)

method name

b)

argument

c)

parameter

d)

method type

6.

It returns the absolute value of z.

a)

absolute(z)

b)

abs(z)

c)

ab(z)

d)

(z)abs

7.

It returns the larger of a and b.

a)

large(a, b)

b)

big(a, b)

c)

min(a, b)

d)

max(a, b)

8.

Which of the following statements is INCORRECT?

a)

Math.abs(-100);

b)

Math.max(2, 4);

c)

Math.sin(10);

d)

Math.pow(2, 3);

9.

List all arguments/actual parameters that exist in this program segment:-

a)

double point, String student

b)

point, student

c)

name, mark

d)

name[i], mark[i]

10.

List all formal parameters that exist in this program segment:-

a)

double point, String student

b)

i, mark

c)

name, mark

d)

name[i], mark[i]

11.

Identify the error that exist in this program segment:-

a)

An array data type cannot be use as argument.

b)

The argument was not in the right sequence with the parameter.

c)

The variable name in parameter not as same with the argument.

d)

Program consist 0 error.

12.

Identify the object that used to call a method.

a)

Status

b)

name[i], mark[i]

c)

mtd

d)

void

13.

Fix the error by replacing with the correct java statement.

a)

void Status(String student, double point)

b)

void Status ( name[i], mark[i] )

c)

int Status(String student, double point)

d)

void Status ( String name[i], double mark[i] )

14.

Create a method name Bonus that will read a basic payment and an hour variable as parameter to calculate an extra salary.

a)
b)
c)
d)
15.

Identify the error that exist in this method program:-

a)

Wrong use of return method type

b)

variable extra was unknown.

c)

doble is not one of the data type

d)

A wrong use of hour data type.

16.

Identify the error that exist in this method program:-

a)

Wrong use of return method type

b)

variable extra was unknown.

c)

doble is not one of the data type

d)

A wrong use of hour data type.

17.

Identify the error that exist in this method program:-

a)

Wrong use of return method type

b)

variable extra was unknown.

c)

All of the parameters data type was not stated.

d)

missing { } in if statement.

18.

What is the Output if the argument is (5500.00, 12.5)

a)

There will be no output.

b)

20, 625.00

c)

27,500.00

d)

34,375.00

19.

What is the Output if the argument is (1300.00, 15.0)

a)

9,750.00

b)

7,800.00

c)

There will be no output.

d)

5,850.00

20.

What is the Output if the argument is (13.0, 2789.00)

a)

14,502.00

b)

10,877.00

c)

18,128.50

d)

There will be no output.

21.

What is the Output if the argument is (1000.00, 14.30)

a)

4,290.00

b)

5,720.00

c)

7,150.00

d)

There will be no output.

22.

Identify types of error that exist in this method program:-

a)

Logic error

b)

runtime error

c)

syntax error

d)

exception

23.

Why method is important?

a)

Break program into a small program and easy to debug.

b)

Easier to read and understand aspecially when involving with a big program.

c)

More practical when we need to reuse the code.

d)

Can store more similar values in a single variable.

24.

What is the order of parameters in a call to the method one?

a)

int, double, char, String

b)

int, double, String, char

c)

int, char, String, double

d)

int, char, double, String

25.

Which of the following Java statements is correct?

a)

System.out.print (one (5, 'r', 1.5, "Hi"));

b)

System.out.print (one (5, 1.5, 'r', "Hi"));

c)

System.out.print (one ("Hi", 'r', 1.5, 5));

d)

System.out.print (one ('r', 5, 1.5, "Hi"));

26.

Which of the following Java statements is correct?

a)

System.out.print (two (t, w, o));

b)

System.out.print (two ("t", "w", "o"));

c)

System.out.print (two (4.0, 4.0, 4.0));

d)

System.out.print (two ('4', '4', '4'));

27.

Which of the following Java statements is correct?

a)

System.out.print (three (17, "Ana", 'f'));

b)

System.out.print (three ("Ana", 'f', 17));

c)

System.out.print (three ("Ana", 17, 'f'));

d)

System.out.print (three ('f', 17, "Ana"));