wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

maths + java-visual

Total questions: 79

Worksheet time: 26mins

Name
Class
Date
1.

Which of the following methods is used to return the smallest possible value (mathematical integer) which is either greater or equal to the argument passed?

a)

ceil()

b)

atan()

c)

copySign()

d)

cosh()

2.

What is the output of the following Java program?

a)

0.0, 0.0

b)

NaN, NaN

c)

Infinity, Infinity

d)

-Infinity, -Infinity

3.

What is the output of the following code snippet?

a)

-4, -6, -4, -5, -4, 0

b)

-6, -4, -5, -4, -4, 0

c)

-4, -4, -5, -5, -4, 0

d)

-6, -6, -5, -5, -4, 0

4.

What is the output of the following code snippet?

a)

10, 10

b)

10, 10.0

c)

10, 10f

d)

10, 10.0f

5.

What is the output of the following code snippet?

a)

-8.3048106211022167, -0.9524129884151565, 0.320048383379563

b)

0.320048383379563, -0.9524129884151565, -8.3048106211022167

c)

-0.9524129884151565, -8.3048106211022167, 0.320048383379563

d)

-8.3048106211022167, 0.320048383379563, -0.9524129884151565

6.

What is the output of the following code snippet?

a)

10.0, 5.0

b)

5.0, 10.0

c)

15.0, 0.0

d)

0.0, 15.0

7.

What is the output of the following code snippet?

Java

int a = 10;

int b = 5;

int c = 0;

System.out.println(Math.gcd(a, b));

System.out.println(Math.gcd(a, c));

Use code with caution. Learn more

a)

5, 0

b)

10, 0

c)

5, 10

d)

0, 10

8.

What is the maximum value that can be generated by the rand() method in the code snippet shown in the image?

a)

10

b)

18

c)

20

d)

25

9.

What is the purpose of the scanner variable in the code snippet shown in the image?

a)

To scan a document.

b)

To scan a barcode.

c)

To get input from the user.

d)

To print output to the console.

10.

What is the result of the Math.pow(2, 10) function in the image?

a)

1024

b)

1000

c)

10

d)

2

11.

What is the output of the code snippet shown in the image?

a)

16

b)

25

c)

36

d)

49

12.

What is the value of the variable result after the code snippet is executed?

a)

3

b)

4

c)

5

d)

6

13.

What is the return type of the pow() method?

a)

int

b)

long

c)

double

d)

float

14.

What is the purpose of the abs() method?

a)

To calculate the absolute value of a number.

b)

To calculate the square root of a number.

c)

To calculate the logarithm of a number.

d)

To calculate the trigonometric value of a number.

15.

What is the output of the code snippet shown in the image?

a)

1

b)

0

c)

-1

d)

NaN

16.

What is the value of the variable intValAbs after the code snippet is executed?

a)

123

b)

-123

c)

0

d)

NaN

17.

What is the output of the code snippet shown in the image?

a)

Error

b)

0

c)

1

d)

5

18.

Which of the following methods returns the smallest integer that is greater than or equal to the argument?

a)

Math.ceil()

b)

Math.floor()

c)

Math.max()

d)

Math.min()

19.

What is the output of the code snippet shown in the image?

a)

10

b)

11

c)

12

d)

13

20.

What is the purpose of the sqrt() method?

a)

To calculate the square root of a number.

b)

To calculate the absolute value of a number.

c)

To calculate the logarithm of a number.

d)

To calculate the trigonometric value of a number.

21.

Which of the following variables are static?

a)

a

b)

b

c)

c

d)

a and c

22.

Which of the following methods is not a method of the Math class?

a)

pow()

b)

ceil()

c)

floor()

d)

sqrt()

23.

Which of the following methods returns the absolute value of a number?

a)

abs()

b)

ceil()

c)

floor()

d)

round()

24.

What is the output of the code snippet shown in the image?

a)

5

b)

10

c)

15

d)

20

25.

What is the purpose of the random() method?

a)

To generate a random integer.

b)

To generate a random floating-point number.

c)

To generate a random number between 0 and 1.

d)

To generate a random number between 0 and the specified maximum value.

26.

What is the output of the code snippet shown in the image?

a)

3

b)

5

c)

7

d)

9

27.

What is the purpose of the ceil() method?

a)

To return the ceiling of a number.

b)

To return the floor of a number.

c)

To return the round of a number.

d)

To return the absolute value of a number.

28.

Which of the following methods returns the smallest integer that is greater than or equal to the specified number?

a)

ceil()

b)

floor()

c)

round()

d)

max()

29.

What is the range of numbers that can be generated by the Math.random() method?

a)

0 to 1

b)

0 to 100

c)

-100 to 100

d)

-10000 to 10000

30.

Which of the following methods is used to calculate the square root of a number?

a)

sqrt()

b)

pow()

c)

abs()

d)

ceil()

31.

Which of the following methods is used to calculate the maximum of two numbers?

a)

max()

b)

min()

c)

abs()

d)

ceil()

32.

Which of the following methods is used to calculate the absolute value of a number?

a)

abs()

b)

round()

c)

ceil()

d)

floor()

33.

Which of the following methods returns the smallest integer that is greater than or equal to the specified number?

a)

ceil()

b)

floor()

c)

round()

d)

max()

34.

Which of the following methods returns the largest integer that is less than or equal to the specified number?

a)

ceil()

b)

floor()

c)

round()

d)

max()

35.

What is the output of the code snippet shown in the image?

a)

3

b)

3.5

c)

4

d)

5

36.

What is the output of the code snippet shown in the image?

a)

4

b)

5

c)

6

d)

7

37.

What is the output of the code snippet shown in the image?

a)

10

b)

11

c)

12

d)

13

38.

Which method in the Java Math class returns the square root of a number?

a)

abs()

b)

ceil()

c)

floor()

d)

sqrt()

39.

Which of the following methods in the Java Math class is used to calculate the absolute value of a number?

a)

abs()

b)

ceil()

c)

floor()

d)

max()

40.

Which of the following methods returns the smallest integer that is greater than or equal to the specified number?

a)

ceil()

b)

floor()

c)

round()

d)

max()

41.

What is the output of the code snippet shown in the image?

a)

3

b)

3.5

c)

4

d)

5

42.

Which of the following methods returns the smallest integer that is greater than or equal to the specified number?

a)

ceil()

b)

floor()

c)

round()

d)

max()

43.

Which of the following methods returns the largest integer that is less than or equal to the specified number?

a)

ceil()

b)

floor()

c)

round()

d)

max()

44.

What is the output of the code snippet shown in the image?

a)

3

b)

6

c)

9

d)

12

45.

What is the output of the code snippet shown in the image?

a)

3.14

b)

6.28

c)

9.42

d)

12.56

46.

What is the expected value of the random variable shown in the image?

a)

0

b)

5

c)

10

d)

15

47.

What is the maximum value of the random variable shown in the image?

a)

0

b)

5

c)

15

d)

10

48.

What is the output of the code snippet shown in the image?

a)

4

b)

NaN

c)

0

d)

1

49.

Which method in the Java Math class returns the smallest integer that is greater than or equal to the specified number?

a)

ceil()

b)

floor()

c)

round()

d)

max()

50.

Which of the following methods in the Java Math class returns the rounded value of the specified number?

a)

ceil()

b)

floor()

c)

round()

d)

max()

51.

What is the output of the code snippet shown in the image?

a)

4

b)

5

c)

6

d)

7

52.

What is the output of the code snippet shown in the image?

a)

3

b)

4

c)

5

d)

6

53.

What is the quadrant of the point (-4, 2)?

a)

Quadrant I

b)

Quadrant II

c)

Quadrant III

d)

Quadrant IV

54.

What is the value of "2+" in Java?

a)

2

b)

4

c)

22

d)

Error

55.

What is the output of the Java program shown in the image?

a)

1

b)

2

c)

3

d)

4

56.

What is the name of the method that is being used to multiply two numbers in the Java code in the image?

a)

multiply()

b)

multiplyExact()

c)

multiplyLong()

d)

multiplyDouble()

57.

Which of the following rounding methods is used by the isPowerOfTwo() method in the image?

a)

Rounding towards zero

b)

Rounding towards positive infinity

c)

Rounding towards negative infinity

d)

Rounding to the nearest even integer

58.

What is the purpose of the program in the image?

a)

To calculate the total number of people in a class.

b)

To calculate the average number of girls and boys in a class.

c)

To calculate the difference between the number of girls and boys in a class.

d)

To print the number of girls and boys in a class.

59.

What is the output of the following code?

a)

23.7

b)

0

c)

-23.7

d)

NaN

60.

What is the trend of the time taken by the Math.exp() function as the input value increases?

a)

The time taken increases linearly.

b)

The time taken increases exponentially.

c)

The time taken decreases linearly.

d)

The time taken decreases exponentially.

61.

Which of the following functions is represented by the graph in the image?

a)

y = log(x)

b)

y = log10(x)

c)

y = loge(x)

d)

y = x

62.

What is the circumference of the circle in the image?

a)

10π

b)

20π

c)

30π

d)

40π

63.

What is the name of the class that is being used to represent a number shape in the image?

a)

Number

b)

Shape

c)

Rectangle

d)

Circle

64.

What is the output of the following Java code?

a)

1.0, -1.0, 0.0

b)

1.0, 1.0, 0.0

c)

-1.0, -1.0, 0.0

d)

0.0, 0.0, 0.0

65.

Which of the following methods is used to round a number to the nearest integer?

a)

Math.round()

b)

Math.ceil()

c)

Math.floor()

d)

Math.trunc()

66.

What is the purpose of the Calculator.java program in the image?

a)

To calculate the natural logarithm (base e) of a number.

b)

To calculate the base 10 logarithm of a number.

c)

To calculate the greater value of two numbers.

d)

To raise a number to the power of another number.

67.

What is the output of the following Java code?

a)

3.141592653589793, 2.718281828459045

b)

2.718281828459045, 3.141592653589793

c)

1.0, 2.0

d)

NaN, Infinity

68.

What is the output of the following Java code?

int x = 10;

int y = 20;

System.out.println(Math.max(x, y));

a)

10

b)

20

c)

30

d)

NaN

69.

What is the output of the following Java code?

a)

1.5625

b)

-1.5625

c)

4.21E-16

d)

NaN

70.

What is the output of the following Java code?
Javaint x = 10;

int y = 10;

System.out.println(Math.max(x, y) == Math.min(x, y));

a)

TRUE

b)

FALSE

c)

NaN

d)

Infinity

71.

What is the output of the following Java code?
double x = 10.0;

double y = 10.0;

System.out.println(Math.abs(x - y));

a)

0

b)

10

c)

0.0

d)

NaN

72.

Which of the following functions is faster?

a)

Math.mean()

b)

FastMath.mean()

c)

Both are equally fast

d)

It depends on the input data

73.

What is the output of the following Java code?
int[] data = {1, 2, 3, 4, 5};

int maxValue = Arrays.stream(data).max().getAsInt();

System.out.println(maxValue);

a)

5

b)

4

c)

3

d)

2

74.

What is the return type of the Integer.parseInt() method?

a)

int

b)

double

c)

float

d)

long

75.

What is the name of the Java math library that focuses on number theory and integer factorization?

a)

Tilman Neumann/java-math-library

b)

Java Math Library

c)

Math library

d)

Number theory library

76.

The exponential and logarithmic methods are used to perform different operations on numbers. Which of the following operations is performed by the exponential method?

a)

Reduce the value of the first argument to zero to the power of the second argument.

b)

Reduce the value of the second argument to zero to the power of the first argument.

c)

Increase the value of the first argument to the power of the second argument.

d)

Decrease the value of the first argument to the power of the second argument.

77.

Which of the following programming languages is best suited for image processing?

a)

Java

b)

Python

c)

C++

d)

MATLAB

78.

What is the value of y after the code is executed?

a)

-4

b)

-2

c)

0

d)

2

79.

What is the maximum x-value of the graph in the image?

a)

0

b)

5

c)

10

d)

20