Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help with Java test questions, I will post the rest of the question in separate post. Question 11 Which of the following shows the

Please help with Java test questions, I will post the rest of the question in separate post.

Question 11

Which of the following shows the proper position of the synchronized keyword in a class declaration?

a.

public int calculate(int x) synchronized

b.

public int synchronized calculate(int x)

c.

public synchronized int calculate(int x)

d.

public int calculate(synchronized int x)

Question 12

Which of the following situations would indicate that a method does not need to be synchronized?

a.

The method contains only a single Java statement.

b.

The method doesnt accept parameters.

c.

The method will never be called by more than one thread.

d.

The method doesnt have a return value.

Question 13

Which of the following statements interrupts the current thread for one second?

a.

Thread.pause(1000);

b.

Thread.sleep(1000);

c.

Thread.wait(1000);

d.

Thread.yield(1000);

Question 14

Which of the following statements is true?

a.

By default, all Java programs use at least two threads.

b.

On a computer with one CPU, threading enables the CPU to execute instructions for multiple threads simultaneously.

c.

On a computer with one CPU, threading enables the CPU to switch between multiple threads that are running.

d.

Threading lets you increase the speed at which the CPU can execute instructions.

Question 15

Which of the following techniques can be used to create a thread?

a.

Implement the Runnable interface, then pass a reference to the object to the startThread method of the System class.

b.

Inherit the Object class, then pass a reference to the object to a constructor of the Thread class.

c.

Inherit the Thread class, then pass a reference to the thread object to the start method of an object that implements the Runnable interface.

d.

Implement the Runnable interface, then pass a reference to the object to a constructor of the Thread class.

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

Advances In Databases And Information Systems Uropean Conference Adbis 2020 Lyon France August 25 27 2020 Proceedings Lncs 12245

Authors: Jerome Darmont ,Boris Novikov ,Robert Wrembel

1st Edition

3030548317, 978-3030548315

More Books

Students also viewed these Databases questions