Mocking Exceptions

Mocking Exceptions

Professional Development

17 Qs

quiz-placeholder

Similar activities

Exceptions and Classes

Exceptions and Classes

Professional Development

21 Qs

JDBC_Objective_Exam_2

JDBC_Objective_Exam_2

Professional Development

15 Qs

FORMATIVE ASSESSMENT 2 OOPS

FORMATIVE ASSESSMENT 2 OOPS

Professional Development

15 Qs

Java Fundamentals

Java Fundamentals

Professional Development

20 Qs

 Java Programming Concepts

Java Programming Concepts

Professional Development

12 Qs

TGA Java - Quiz 3

TGA Java - Quiz 3

Professional Development

15 Qs

Chapter 8 : Debugging and Error Handling

Chapter 8 : Debugging and Error Handling

Professional Development

20 Qs

Exception

Exception

Professional Development

20 Qs

Mocking Exceptions

Mocking Exceptions

Assessment

Quiz

Computers

Professional Development

Hard

Created by

ANIL KUMAR

FREE Resource

17 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you mock exceptions in Mockito?
a) By using doThrow() and verify() methods.
b) By using when() and thenThrow() methods.
c) By using doReturn() and assertThrows() methods.
d) By using mock() and expect() methods.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is mocking in Java?
a) A process of removing all exceptions from code.
b) A technique to create controlled unit testing environments.
c) A method to ignore external dependencies in unit testing.
d) A process of simulating user interactions in Java applications.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How to mock the checked exception in Java?
a) By using @Test(expectedExceptions = SomeException.class)
b) By using doThrow(new SomeException()) in mock objects.
c) By using catch blocks in test cases for checked exceptions.
d) By using mock() and expect() methods for checked exceptions.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you catch exceptions in Mockito?
a) By using catch blocks in test cases.
b) By using verify() and expect() methods.
c) By using assertThrows() and try-catch blocks.
d) By using try-catch blocks in test cases.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is an example of mock testing?
a) Validating calls without side effects and avoiding code duplication.
b) Simulating real user interactions in unit testing.
c) Testing exceptions by throwing them from mock objects.
d) Testing external dependencies in isolation.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How to mock an error response?
a) By throwing an exception inside a request handler.
b) By composing a valid response using res() composition chain.
c) By simulating network errors in unit tests.
d) By using the mock() and expect() methods.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Why do we use mocking?
a) To remove exceptions from the code.
b) To simulate user interactions in testing.
c) To isolate the code being tested from external dependencies.
d) To generate random test data.

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?