Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Practice Questionson Multithreading and Junit

Total questions: 62

Worksheet time: 31mins

Name
Class
Date
1.

How many ways a thread can be created in Java multithreading?

a)

1

b)

2

c)

5

d)

10

2.

Which method is used to make main thread to wait for all child threads

a)

Join ()

b)

Sleep ()

c)

Wait ()

d)

Stop ()

3.

Which will contain the body of the thread in Java?

a)

Start()

b)

Run()

c)

Main()

d)

Execute()

4.

The life cycle of a thread in java is controlled by

a)

JRE

b)

JDK

c)

JVM

d)

None

5.

Which method is used to get current running thread object?

a)

runningThread()

b)

currentThread()

c)

runnableThread()

d)

None

6.

Synchronized static methods acquire lock on

a)

Class

b)

Object

c)

Interface

d)

None

7.

Thread priority in Java is?

a)

Integer

b)

Float

c)

Double

d)

Long

8.

In JAVA multi threading, a thread can be created by_______

a)

Extending class

b)

Implementing Runnable Interface

c)

both

d)

none

9.

Which statements is/are correct

a)

On calling Thread start ( ) method a new thread is created

b)

Thread start( ) method call run( ) method internally

c)

Thread run( ) method can also be called directly to create thread

d)

both a & b

10.

Q) What is maximum thread priority in Java

a)

10

b)

12

c)

5

d)

8

11.

Q) Number of threads in below java program is

public class ThreadExtended extends Thread {


public void run() {

System.out.println("\nThread is running now\n");

}


public static void main(String[] args) {


ThreadExtended threadE = new ThreadExtended();


threadE.start();

}

}

a)

0

b)

1

c)

2

d)

3

12.

Q) Execution of a java thread begins on which method call?

a)

Start ()

b)

Run ()

c)

Execute ()

d)

Launch ()

13.

Q) Which method is used to check if a thread is running?

a)

isAlive()

b)

run ()

c)

alive ()

d)

keepAlive()

14.

Q) Min and Max priority of a thread in Java multithreading are

a)

1, 10

b)

0,10

c)

0,255

d)

1,256

15.
What is sometimes also called a lightweight process?
a)
Thread
b)
Process
c)
JVM
16.
Which of these is not a Thread state?
a)
New
b)
Runnable
c)
sleep
d)
terminated
17.

___________distributing task across multiple computing cores

a)

data parallelism

b)

implicit threading

c)

task parallelism

d)

identifying task

18.

Execution of a java thread begins on which method call?

a)

Run ()

b)

Start ()

c)

Execute ()

d)

Launch ()

19.

Choose THREE(3) benefits of multithreaded processing

a)

scalability

b)

resource sharing

c)

privacy

d)

responsiveness

20.

Thread is _____________process that can run independently

a)

heavyweight

b)

lightweight

c)

compaction

d)

compression

21.

Which of the following describes Testing correctly?

a)

A - Testing is the process of checking the functionality of the application whether it is working as per requirements.

b)

B - Testing is the testing of single entity (class or method).

c)

C - Both of the above.

d)

D - None of the above.

22.

Which of the following class contains methods to collect the results of executing a test case?

a)

A - Assert

b)

B - TestCase

c)

C - TestResult

d)

D - TestSuite

23.

Is it necessary to write the test case for every logic?

a)

Yes

b)

No

24.

If the JUnit method's return type is 'string', what will happen?

a)

the execution will Pass

b)

the execution will fail.

c)

the execution will Not Excute

d)

syntax error

25.

Is it necessary to write the test class to test every class?

a)

Yes

b)

NO

26.

Which method is used to verify the actual and expected results in Junits?

a)

equals()

b)

isEqual()

c)

==

d)

assert()

27.

JUnits are used for which type of testing?

a)

Blackbox Testing

b)

Unit Testing

c)

System Testing

d)

Integration Testing

28.

Assert contains a set of assert methods.

a)

A - true

b)

B - false

29.

Automated Test cases are executed by using automation tool so less tester are required in automation testing.

a)

A - true

b)

B - false

30.

what is integration testing??

a)

Testing the each module individually

b)

Tetsing two or more modules after combining

31.

Is there any direct way to test "Private Method"?

a)

Yes

b)

No

32.

Is JUnit only report the first failure in a single test ?

a)

Yes

b)

No

33.

What is the most basic type of developer level test?

a)

Integration Test

b)

Universal Test

c)

Unit Test

d)

Basic Test

34.

Which of the following is not a desirable quality of "a unit test"?

a)

Tests one property at one time

b)

Fast

c)

I/O or File Operations

d)

Covering a small portion of code

35.

What is the significance of writing a failing test?

a)

We should not. We should focus on writing a test that passes

b)

A failing test shows that some code change is required in our program. If it is not failing, no change required.

c)

A failing test shows that the previous developer didn't do a good job.

d)

A failing test gives you an opportunity to enhance code coverage

36.

What is a test?

a)

A measure to check if the code meets the defined specifications

b)

A measure to check if the code is visually beautiful

c)

A measure to check if the code contains security vulnerabilities?

d)

A measure to increase code coverage

37.

I need to test if a service method is fine or not. What type of test do I need to write?

a)

Unit Test

b)

Integration Test

c)

Selenium Test

d)

Black Box Test

38.

Which of the following describes Testing correctly?

a)

A - Testing is the process of checking the functionality of the application whether it is working as per requirements.

b)

B - Testing is the testing of single entity (class or method).

c)

C - Both of the above.

d)

D - None of the above.

39.

Which of the following class contains methods to collect the results of executing a test case?

a)

A - Assert

b)

B - TestCase

c)

C - TestResult

d)

D - TestSuite

40.

Which of the following annotation causes that method run once after all tests have finished?

a)

A - @Test

b)

B - @After

c)

C - @BeforeClass

d)

D - @AfterClass

41.

Which of the following method of Assert class checks that an object is null?

a)

A - void assert(Object object, boolean toCheckAsNull)

b)

B - void assertCheck(Object object, boolean toCheckAsNull)

c)

C - void assertNull(Object object)

d)

D - void assertChecks(Object object, boolean toCheckAsNull)

42.

@RunWith and @Suite annotation are used to run the suite test.

a)

A - false

b)

B - true

43.

Automated Test cases are executed by using automation tool so less tester are required in automation testing.

a)

A - true

b)

B - false

44.

Assert contains a set of assert methods.

a)

A - true

b)

B - false

45.

Which of the following method of Assert class checks that a condition is true?

a)

A. void assert(boolean condition)

b)

B. void assertTrue(boolean condition)correct

c)

C. void assertCheck(boolean condition)

d)

D. void assertChecks(boolean condition)

46.

Which of the following method of TestSuite class adds the tests from the given class to the suite?

a)

A. void addTest(Class testClass)wrong

b)

B. void addTestSuite(Class testClass)correct

c)

C. void addTest(TestCase testClass)

d)

D. void addTestCase(TestCase testClass)

47.

JUnits are used for which type of testing?

a)

Blackbox Testing

b)

Unit Testing

c)

System Testing

d)

Integration Testing

48.

Which of the below is an incorrect annotation with respect to JUnits?

a)

@Junit

b)

@AfterEach

c)

@Test

d)

@BeforeClass

49.

Which method is used to verify the actual and expected results in Junits?

a)

equals()

b)

isEqual()

c)

==

d)

assert()

50.

What does assertSame() method use for assertion?

a)

equals() method

b)

isEqual() method

c)

==

d)

compare() method

51.

What is the use of Junit

a)

To increase code coverage

b)

To test unit of code thoroughly

c)

To integrate with other units of code

52.

Is it necessary to write the test case for every logic?

a)

Yes

b)

No

53.

Is there any direct way to test "Private Method"?

a)

Yes

b)

No

54.

Is JUnit only report the first failure in a single test ?

a)

Yes

b)

No

55.

What is the most basic type of developer level test?

a)

Integration Test

b)

Universal Test

c)

Unit Test

d)

Basic Test

56.
The best way to avoid problems is to write the program before writing the algorithm.
a)
True
b)
False
57.

which of the following are framework of testings (testing frameworks)

a)

JUNIT

b)

JUNIT and WordPress

c)

Selenium

d)

Selenium and REST

58.

Assert.assertEquals(calculadoraSimple.suma("1", "2"), 5);

a)

Assert OK

b)

Assert Failure

c)

Assert Exception

59.

Assert.assertEquals(calculadoraSimple.suma(null, "2"), 5);

a)

Assert OK

b)

Assert Failure

c)

Assert Exception

60.

Assert.assertNotEquals(calculadoraSimple.suma("5", "2"), 3);

a)

Assert OK

b)

Assert Failure

c)

Assert Exception

61.

@Test(expected = RuntimeException.class)

...

Assert.assertEquals(calculadora.suma(null, "2"), 3);

a)

Assert OK

b)

Assert Failure

c)

Assert Exception

62.

MAVEN needs

a)

web.xml

b)

manifest.yml

c)

pom.xml

d)

all of them