Search Header Logo

Setup Mocking

Authored by ANIL KUMAR

Computers

Professional Development

Setup Mocking
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

26 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

How to create a mock in Java?

a) Create fake objects from real classes/interfaces.
b) Call MockitoAnnotations.initMocks(this).
c) Set up the JAVA environment.
d) Use the Mockito.mock() method.

2.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

How to initialize a mock object in Java?

a) Call MockitoAnnotations.initMocks(this).
b) Create an interface with unimplemented methods.
c) Use @RunWith(MockitoJUnitRunner.class).
d) Set up the CLASSPATH variable.

3.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

How do I set up Mockito?

a) Download the Mockito-All archive.
b) Verify Java installation.
c) Set up the JAVA environment.
d) Set up the JUnit environment.

4.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

How does mocking work in Java?

a) Mocking removes external dependencies from a unit test.
b) Mocking involves creating fake objects.
c) Mocking verifies method execution and arguments.
d) Mocking simulates behavior using Mockito annotations.

5.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

How to implement Mockito in Java?

a) Create an interface with unimplemented methods.
b) Set up the Mockito environment.
c) Use the Mockito.mock() method.
d) Download the Mockito-All archive.

6.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

What is the difference between @InjectMocks and @Autowired?

a) @InjectMocks injects dependencies into non-test classes.
b) @Autowired replaces dependencies in a test class.
c) @InjectMocks is used in Spring framework.
d) @Autowired is used in Mockito framework.

7.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Can I mock a class in Java?

a) Yes, using the Mockito.mock() method.
b) No, Mockito only mocks interfaces.
c) Yes, using the @Autowired annotation.
d) No, mocking is not supported in Java.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?