- Which of the following is a popular Java mocking framework?
View Answer
Correct answer: A — Mockito
- In Python, the standard library for mocking is:
View Answer
Correct answer: A — unittest.mock
- JMockit is primarily used for:
View Answer
Correct answer: A — Mocking and stubbing in Java
- Which Mockito method verifies method calls?
View Answer
Correct answer: A — verify()
- In unittest.mock, which function creates a mock object?
View Answer
Correct answer: A — Mock()
- Which of the following is NOT a mocking concept?
View Answer
Correct answer: D — Compiling
- Mockito's when(...).thenReturn(...) is used for:
View Answer
Correct answer: A — Stubbing behavior
- In unittest.mock, patch() is used to:
View Answer
Correct answer: A — Replace objects during tests
- JMockit supports mocking of:
View Answer
Correct answer: A — Static methods
- Which of the following best describes a stub?
View Answer
Correct answer: A — Provides predefined responses
- What will be printed?
1 import static org.mockito.Mockito.*; 2 public class EduinqMockTest { 3 public static void main(String[] args) { 4 List<String> mockList = mock(List.class); 5 when(mockList.size()).thenReturn(5); 6 System.out.println("Eduinq size: " + mockList.size()); 7 } 8 } View Answer
Correct answer: A — Eduinq size: 5
- In unittest.mock, MagicMock differs from Mock by:
View Answer
Correct answer: A — Supporting magic methods
- Mockito's spy() is used to:
View Answer
Correct answer: A — Wrap real objects and monitor calls
- Which of the following is true about mocks?
View Answer
Correct answer: A — They simulate dependencies
- JMockit supports verification using:
View Answer
Correct answer: A — Verifications block
- In unittest.mock, side_effect is used to:
View Answer
Correct answer: A — Define custom behavior or exceptions
- Mockito supports argument capturing using:
View Answer
Correct answer: A — ArgumentCaptor
- Which of the following is NOT a Python mocking tool?
View Answer
Correct answer: C — JMockit
- JMockit supports mocking constructors using:
View Answer
Correct answer: A — Expectations block
- Which of the following best describes a spy?
View Answer
Correct answer: A — Wraps real objects and records calls
- What will be printed?
1 from unittest.mock import Mock 2 eduinq_mock = Mock() 3 eduinq_mock.get_name.return_value = "Eduinq" 4 print(eduinq_mock.get_name()) View Answer
Correct answer: A — Eduinq
- Mockito's any() matcher is used for:
View Answer
Correct answer: A — Matching any argument
- In unittest.mock, assert_called_once() verifies:
View Answer
Correct answer: A — Method was called exactly once
- JMockit supports mocking private methods using:
View Answer
Correct answer: A — Expectations block
- Which of the following is true about stubs?
View Answer
Correct answer: A — They provide fixed responses
- Mockito's doReturn(...).when(...) is used for:
View Answer
Correct answer: A — Stubbing void methods
- In unittest.mock, assert_not_called() verifies:
View Answer
Correct answer: A — Method was never called
- JMockit supports mocking static methods using:
View Answer
Correct answer: A — Expectations block
- Which of the following best describes verification in mocking?
View Answer
Correct answer: A — Ensures expected calls were made
- PyTest integrates mocking using:
View Answer
Correct answer: A — pytest-mock plugin
- What will be printed?
1 import static org.mockito.Mockito.*; 2 public class EduinqSpyTest { 3 public static void main(String[] args) { 4 List<String> list = new ArrayList<>(); 5 List<String> spyList = spy(list); 6 spyList.add("Eduinq"); 7 System.out.println(spyList.get(0)); 8 } 9 } View Answer
Correct answer: A — Eduinq
- In unittest.mock, call_args stores:
View Answer
Correct answer: A — Arguments of the last call
- Mockito supports throwing exceptions using:
View Answer
Correct answer: A — thenThrow()
- JMockit supports recording expectations using:
View Answer
Correct answer: A — Expectations block
- Which of the following is true about spies?
View Answer
Correct answer: A — They wrap real objects
- In unittest.mock, assert_called_with() verifies:
View Answer
Correct answer: A — Method was called with specific arguments
- Mockito supports deep stubs using:
View Answer
Correct answer: A — mock(Class, RETURNS_DEEP_STUBS)
- JMockit supports mocking final classes using:
View Answer
Correct answer: A — Expectations block
- Which of the following is true about mocks vs stubs?
View Answer
Correct answer: A — Mocks verify interactions, stubs provide responses
- PyTest's monkeypatch fixture is mainly used for:
View Answer
Correct answer: A — Modifying or replacing functions during tests
- Mockito's reset() method is used to:
View Answer
Correct answer: A — Clear interactions and stubs on a mock
- In unittest.mock, patch.object() is used to:
View Answer
Correct answer: A — Replace attributes of an object
- JMockit supports mocking final methods using:
View Answer
Correct answer: A — Expectations block
- Which of the following is true about spies in Mockito?
View Answer
Correct answer: A — They allow partial mocking of real objects
- In unittest.mock, patch.dict() is used to:
View Answer
Correct answer: A — Temporarily modify dictionaries
- Mockito's verifyNoMoreInteractions() is used to:
View Answer
Correct answer: A — Ensure no unexpected calls were made
- JMockit supports mocking static initializers using:
View Answer
Correct answer: A — Expectations block
- Which of the following best describes a fake object?
View Answer
Correct answer: A — Provides a working implementation with simplified logic
- In unittest.mock, patch.multiple() is used to:
View Answer
Correct answer: A — Patch multiple attributes at once
- Which of the following best describes mocking frameworks?
View Answer
Correct answer: A — They simulate dependencies for isolated testing