JUnit interview questions part 1

JUnit interview questions part 1

Take as many assements as you can to improve your validate your skill rating

Total Questions: 20

1. Which of the following is correct about JUnit?

Correct Answer is : Both of the above.

2. Which of the following is correct about Test Suite in JUnit?

Correct Answer is : Both of the above

3. Which of the following annotation causes that method to be run before each Test method?

Correct Answer is : @Before

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

Correct Answer is : void assertTrue(boolean condition)

5. Which of the following method of TestCase class sets up the fixture, for example, open a network connection?

Correct Answer is : void setUp()

6. JUnits are used for which type of testing?

Correct Answer is : Unit Testing

7. Which of the below statement about JUnit is false?

Correct Answer is : They cannot be run automatically

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

Correct Answer is : @Junit

9. Which of these is not a mocking framework?

Correct Answer is : MockJava

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

Correct Answer is : assert()

11. What does assertSame() method use for assertion?

Correct Answer is : #ERROR!

12. How to let junits know that they need to be run using PowerMock?

Correct Answer is : @RunWith(PowerMockRunner.class)

13. How can we simulate if then behavior in Junits?

Correct Answer is : Mockito.when(…).thenReturn(…);

14. What is used to inject mock fields into the tested object automatically?

Correct Answer is : @InjectMocks

15. How can junits be implemented using maven?

Correct Answer is : junit junit 4.8.1

16. Which one of the following provides all dependencies in the makefile?

Correct Answer is : Beta

17. In which condition this prgram will print the string “Sanfoundry”? #include #include  int main() { int *ptr; ptr = (int *)malloc(sizeof(int)*10); if (ptr == NULL) printf("Sanfoundry\n"); return 0; }

Correct Answer is : Test execution engine

18. This program will allocate the memory of ___ bytes for pointer “ptr”. #include #include  int main() { int *ptr; ptr = (int*)malloc(sizeof(int)*4); ptr = realloc(ptr,sizeof(int)*2); return 0; }

Correct Answer is : untested

19. In this program the allocated memory block can store #include #include  int main() { int *ptr; ptr = malloc(10); return 0; }

Correct Answer is : Objects

20. This program will allocate the memory of ___ bytes for pointer “ptr”. #include #include  int main() { int *ptr; ptr = realloc(0,sizeof(int)*10); return 0; }

Correct Answer is : Expectation

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon