Invitation to Authors

Interested in writing a book for us?

Please fill this form and get a chance to get published plus $200 bonus online coupon.

PayPal Logo
JUnit Interview Questions You\'ll Most Likely Be Asked
JUnit Interview Questions You'll Most Likely Be Asked

ISBN: 9781465758705

Price:   $19.95

Quantity :        
Book Description:

JUnit Interview Questions You'll Most Likely Be Asked is a perfect companion to stand ahead above the rest in today’s competitive job market. Rather than going through comprehensive, textbook-sized reference guides, this book includes only the information required immediately for job search to build an IT career. This book puts the interviewee in the driver's seat and helps them steer their way to impress the interviewer.


Table of Contents
1. Rules
2. Assertions
3. Test Classes
4. Running Tests
5. Unit Testing and JUnit Features
6. JUnit 3
7. JUnit API
8. JUnit4.x
9. Test Class and Annotations
10. HR Questions


a) 200 JUnit Interview Questions, Answers and Proven Strategies for getting hired as an IT professional

b) Dozens of examples to respond to interview questions

c) 51 HR Questions with Answers and Proven strategies to give specific, impressive, answers that help nail the interviews

d) 2 Aptitude Tests download available on



Sample from the book
(Below Questions and Answers are randomly taken from different pages of the book)

176: How will you check whether the object is null?


a) Using assertNull(...)

String s1= null;

assertNull(“this string object should be null here”,s1);


177: How will you verify whether two object reference points to different objects?


a) Using assertNotSame(...)


List fruitList = new ArrayList();

List vegList = new ArrayList();


assertNotSame(“Both objects should not be same”,fruitList, vegList);


178: Can we overload assert equals method?


Yes. Each function statement will confirm that the tests pass or fail.

public class DemoTestClass extends TestCase


public void calcSal() {

assertEquals( 5, (int) Math . max(5,10) ); // test fail

assertEquals( 5, (int) Math . min(5,10) ); // test pass




fail() function


179: How will you display a message if test fails?


a) Using fail() method.



Public void calcSalTest() {

If (sal == 0)

fail(“Test failed”);



180: How will you throw an exception in your testcase?



Public void calcSalTest() {

Deal deal = null;

try {

if (sal> 20000) {

deal=new Deal();



fail(“Test failed. Null Pointer exception.”);


Catch (Exception e) {





Handling Throwable


181: How will you handle exceptions without using fail()?


a) Using AssertionFailedError.

b) Will identify the source of the problem instead of displaying the location from where fail() is invoked.


import junit.framework.AssertionFailedError;

public void DemoTest1() {

try {



catch ( SQLExceptionsqlex) {

AssertionFailedErroraferr = new AssertionFailedError(sqlex.getMessage());






182: How will you handle when a method declared as ‘checked exceptions’ is called from your test method?


Declaring these kind of methods in the test code itself is not sufficient. They should be either handled by

a) A java try/catch or

b) Expected attribute of junit




New Title Idea Submission

Got a fantastic New Title Idea but didn't find it in our catalogue?

Please fill this form and see your idea getting published. Also a chance to win $100 coupon.

Visitor Rating : 10/ 10 Based on 590 ratings.