Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the Java API page for the floor method, it lists the signature as public static double floor(double a) Given this information, which of the

In the Java API page for the floor method, it lists the signature as

public static double floor(double a)

Given this information, which of the following statements will compile and run without errors (assuming they're inside an otherwise valid program)?

Math.floor(8.9) = double x;

int x = Math.floor(8.9);

double x = floor(8.9);

double x = Math.floor(8.9);

What happens when we write this code snippet? int x = 1; int x = x + 1; x = x + 1; System.out.println(x);

Question 2 options:

It has a compile error because on the third line the type of x is not specified

It compiles, but has a runtime error when printing x because x has multiple values during the program

It compiles and runs correctly, and prints 3

It has a compile error because x cannot be declared twice

Which of the following code snippets compiles and correctly prints the square root of 2?

Question 3 options:

Math m = new Math(); System.out.println(m.sqrt(2));

Math.print(sqrt(2));

System.out.println(Math.sqrt(2));

System.out.println(sqrt(2));

Question 4 (1 point)

Which of the following could NOT possibly be the output of this code snippet? Random rg = new Random(); int x = rg.nextInt(7); System.out.println(x);

Question 4 options:

1

6

0

7

Question 5 (1 point)

Which of the following is NOT an example of an expression?

Question 5 options:

7

kb.nextInt()

"Hello world!"

String name;

Question 6 (1 point)

What output would be produced by this code snippet? System.out.print(8); System.out.println("cats"); System.out.print(7);

Question 6 options:

8.0cats 7.0

8cats7

8cats 7

8 cats 7

Question 7 (1 point)

Assuming x has been declared as an int, what does the following line of code do?

x = 7;

Question 7 options:

It assigns the value 7 to the memory allocated for the variable x.

This line of code has an error and does not compile.

This line of code is legal but has no effect.

It checks if the value stored in the memory for x is equal to 7.

Question 8 (1 point)

What is output by this code snippet? String s = "Hi friend!"; s.replace('i','A'); System.out.println(s);

Question 8 options:

HA frAend!

HA

HA friend!

Hi friend!

Question 9 (1 point)

What is the output of this code snippet? int x = 5; System.out.println(x / 2);

Question 9 options:

5

2

None, there is a compile error

2.5

Question 10 (1 point)

The syntax of a language is best described as:

Question 10 options:

The rules for how the symbols can be arranged

The font and color the language should be written in

The meaning of the language's symbols in particular arrangements

The development environment where a language can be written

Question 11 (1 point)

While there are many valid definitions for computer science, in class we said computer science is:

Question 11 options:

the process of writing programs, and only if they're in Java

the study of what can be computed

the study of telescopes

the study of computers

Question 12 (1 point)

In Java, the outermost block of code must be:

Question 12 options:

A class

A main method

A comment

A declaration statement

Question 13 (1 point)

When we write a main method for our Java programs, its signature (also called its declaration or "header") must be:

Question 13 options:

public class main(String args)

static void main()

private int main(String[] args)

public static void main(String[] args)

Question 14 (1 point)

Suppose we want to get an int value that is typed by the user with the line int value = kb.nextInt(); Which of these lines must appear somewhere before that line in our code?

Question 14 options:

Scanner kb = new Random();

Keyboard kb = new Keyboard();

Scanner kb = new Scanner(System.in);

new Scanner kb;

Question 15 (1 point)

The semantics of a language is best described as:

Question 15 options:

The development environment where a language can be written

The meaning of the language's symbols in particular arrangements

The font and color the language should be written in

The rules for how the symbols can be arranged

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions

Question

Explain all drawbacks of the application procedure.

Answered: 1 week ago

Question

Determine Leading or Lagging Power Factor in Python.

Answered: 1 week ago