Question: 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

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!