Java8 Qualis Interview Question-Answer

Java8 Qualis Interview Question-Answer

Java8 Overview

JAVA 8 is a major feature release of JAVA programming language development. Its initial version was released on 18 March 2014. With the Java 8 release, Java provided supports for functional programming, new JavaScript engine, new APIs for date time manipulation, new streaming API, etc.

New Features

  • Lambda expression − Adds functional processing capability to Java.
  • Method references − Referencing functions by their names instead of invoking them directly. Using functions as parameter.
  • Default method − Interface to have default method implementation.
  • New tools − New compiler tools and utilities are added like ‘jdeps’ to figure out dependencies.
  • Stream API − New stream API to facilitate pipeline processing.
  • Date Time API − Improved date time API.
  • Optional − Emphasis on best practices to handle null values properly.
  • Nashorn, JavaScript Engine − A Java-based engine to execute JavaScript code.

Q.1 Code Snippet

@BeforeAll public void ResetCounterBeforeTestcase() throws Exception { counter = 0; }

While executing a test class, how many times the given section of code will get executed if there are three test methods defined in the class?

       A. Three times

       B. Never

       C. Two times

       D. Once

Ans : Once


Q.2 Which of the following annotation causes that method run after each test methods?

       A. @AfterEach

       B. @AfterAll

       C. @BeforeAll

       D. @test

Ans : @AfterEach


Q.3 Which of the following is not an optional parameter defined for the @Test annotation?

       A. timeout

       B. threadcount

       C. expected

       D. None of the options

Ans : threadcount


Q.4 Which of the following is true about JUnit?

       A. JUnit provides test fixtures to share the common test data

       B. JUnit is a testing framework for Java

       C. JUnit is an open source framework

D. All the options

Ans : All the options


Q.5 Which of the following method asserts that both the objects refer to the same object?

       A. assertSame(obj1,obj2)

       B. assertnotSame(obj1,obj2)

       C. assertFalse(obj1==obj2)

       D. assertEquals(obj1=obj2)

Ans : assertSame(obj1,obj2)


Q.6 Logical collection of test classes can be bundled together to form a __________.

       A. Runner

       B. Suite

       C. Filter

       D. Fixture

Ans : Suite


Q.7 Which JUnit annotation allows you to define order of execution for the test methods?

       A. @FixMethodOrder

       B. @Rule

       C. @DefineOrder

       D. @Ignore

Ans : @FixMethodOrder


Q.8 Which sorter methods will execute the text methods in the lexicographic order of their names?

       A. MethodSorters.NAME_ASCENDING

       B. MethodSorters.LEXICOGRAPHIC_SORTER

       C. MethodSorters.Default

 D. MethodSorters.JVM

Ans : MethodSorters.NAME_ASCENDING


Q.9 For any JUnit method, the return type should be __________.

       A. Void

       B. Object

       C. String

       D. Null

Ans : Void


Q.10 Test cases are executed with a fixed state of object which can be a baseline for running tests to ensure the results are repeatable, such object are called __________.

       A. Fixture

       B. Froster

       C. StableSet

       D. Frontier

Ans : Fixture


Q.11 Which of the following can Mockito mock?

       A. Static methods

       B. Enum

       C. Public methods

       D. Final methods

Ans : Public methods


Q.12 JUnit tests will be executed in the same order in which they are written.

       A. True

       B. False

Ans : False


Q.13 Mockito can mock private methods.

A. True

       B. False

Ans : False


Q.14 Which among the following is a test double?

       A. A fake object

       B. A dummy object

       C. Mock object

       D. All of these

Ans : All of these


Q.15 Which among the following test double is used to replace a target function with pre programmed method directing to specific path? Choose the correct option from below list

       A. Mocks

       B. Stub

       C. Spie

       D. Dummies

Ans : Stub


Q.16 Mockito can inject mocks via ________.

       A. Predictive Injection

       B. Constructor Injection

       C. Desructive Injection

       D. None of the options

Ans : Constructor Injection

Q.17 Mockito framework offers _______ to compute on-the-fly results.

       A. Stubbing

       B. Callbacks

       C. AdaptiveResponse

       D. Setbacks

Ans : Callbacks


Q.18 Mockito can throw an exception using which of the following?

       A. when().thenReturn()

       B. when().thenAnswer()

       C. doWhen().thenThrow()

       D. when().thenThrow()

Ans : when().thenThrow()

Click here to read more Education Q&A


Q.19 MockMvc tests the expected response details that are configured using _______ calls after performing a request.

       A. .andGet()

       B. .perform()

       C. .andDo(print())

       D. .andExpect()

Ans : .andExpect()


Q.20 _____ is a class level annotation to indicate the Application context for the test that will be Web application context.

       A. @ServersideConfiguration

       B. @JsonConfiguration

       C. @WebAppConfiguration

       D. @RestApplication

Ans : @WebAppConfiguration


Q.21 _____ forms the integral part of Spring Testing framework.

       A. PowerMock

       B. Mockito

       C. MockMVC

       D. PowerMVC

Ans : MockMVC


Q.22 Integration of JUnit and the Spring Test context framework is done by _____ runner.

       A. Cucumber Runner

       B. MockitoJUnitRunner

       C. SpringJUnit4ClassRunner

       D. HierarchicalContextRunner

Ans : SpringJUnit4ClassRunner


Q.23 MockMvc is used to mock the entire Spring MVC infrastructure. True or False.

       A. True

       B. False

Ans : False

Java 8 Qualis Interview Questions and Answers

Q.1 MockMvc builder ______ tests one controller at a time.

       A. xmlConfigSetup

       B. annotationConfigSetup

       C. standaloneSetup

       D. webAppContextSetup

Ans : standaloneSetup

Click here to read more blogs

About Author


After years of Technical Work, I feel like an expert when it comes to Develop wordpress website. Check out How to Create a Wordpress Website in 5 Mins, and Earn Money Online Follow me on Facebook for all the latest updates.

Leave a Comment