Blog Archives
1 2 3 4 5

00: Ensuring code quality in Java Q&As

Q1. How do you ensure code quality in your application? A1. Code quality means writing readable, maintainable and robust code, that conforms as much as possible to the style-guideline that is used, and that has as little as possible defects. … Read more ›...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


01: 6 JUnit & JMockit interview questions & answers on Java Unit testing – Part 1

JUnit & JMockit interview questions & answers extends 5 Java unit testing interview Questions and Answers. Unit testing is widely accepted as a “best practice” for your Java code quality. If you are after in-depth tutorials on JMockit, refer to JMockit tutorials by Shetty Tech Talks. … Read more ›...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


01: JMockit interview Q&As & examples on @Injectable Vs @Mocked Vs @Capturing Vs @Tested

This extends 6 JUnit & JMockit interview questions & answers on Java Unit testing – Part 1. It is very essential to understand how these 3 annotations work in JMockit to write unit tests quickly & effectively.

Q1 What is the difference between @Injectable and @Mocked in JMockit?

Read more ›



01: JUnit with Mockito tutorial step by step

JUnit with Mockito tutorial step by step. Mockito is a popular mocking framework used along with JUnit. JMockit is more popular than Mockito.

Step 1: Create a simple maven project say “code-quality”

Step 2: Import into eclipse.

Read more ›



01: jvisualvm tutorial to sample Java heap memory

Java does not have a sizeof operator like C++ does. Java uses automatic memory management known as the Garbage Collection, hence it is not that important to evaluate size of various objects. But, for the purpose of learning & fixing any potential memory issues, I have used “jvisualvm”, … Read...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


01: Mockito interview Q&As & examples on @Mock, @Spy, @Captor and @InjectMocks

Firstly, you need the pom.xml entry to bring in the Mockito library.

@InjectMocks

Firstly, annotate the Test class with @RunWith(MockitoJUnitRunner.class) as shown below. The @InjectMocks annotation creates an instance of the class and injects the mocks that are created with the @Mock (or @Spy) annotations into this instance.

Read more ›



02: 6 JUnit & JMockit interview questions & answers on Java Unit testing – Part 2

This extends 6 JUnit & JMockit interview questions & answers on Java Unit testing – Part 1. JUnit & JMockit interview questions and answers to write unit testing in Java for better code quality. JUnit interview questions are popular. Q7 What can you mock with JMockit? … Read more ›...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


02: JMockit interview Q&As & examples on Expectations & Verifications

This extends 01: JMockit interview Q&As on @Injectable Vs @Mocked Vs @Tested. The purpose of mocking objects is to return an expected value to test the logic of the class under test. This can be achieved with JMockit Expectations.

An expectation represents a set of invocations to a specific mocked method/constructor that is relevant for a given test.

Read more ›



02: jvisualvm to detect memory leak – a quick tutorial style Java demo

This is a companion post to 8 Java Memory Management Interview Q&A demonstrating a memory leak scenario step by step with jvisualvm, which is a free profiling tool that gets shipped with JDK. Step 1: Code that causes memory leak Here is a sample code that causes memory leak. …...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


02: Mockito interview Q&As & examples on @Spy

A spy in mockito is a partial mock where part of the object will be mocked and part will use real method invocations. You can create a Spy a number of different ways. Consider using mocks instead of spies wherever possible as having to use a Spy could indicate violating...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


02: Unit testing with JUnit, Mockito & Spring

Step 1: Create a simple Maven project from a command-line. Just press enter for all the prompts.

Step 2: Import the above “simple-mocking-test” in the file system into eclipse. File –> Import –> “Existing Maven Projects” and then select the “simple-mocking-test”

Read more ›



03: JMockit interview Q&As & examples on initialising @Injectable fields

This extends 02: JMockit interview Q&As & examples on Expectations & Verifications. We have already discussed that a non-final instance field annotated as @Tested in the test class will be considered for automatic instantiation and injection, just before the execution of a test method. … Read more ›...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


03: JUnit & Mockito Interview Questions & Answers

JUnit & Mockito interview questions & answers extends 5 Java unit testing interview Questions and Answers. Unit testing is widely accepted as a “best practice” for your Java code quality. You can also refer to 6 JUnit & JMockit interview questions & … Read more ›...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


1 2 3 4 5

300+ Java Interview FAQs

Tutorials on Java & Big Data