Java MCQ Number 01083

Java MCQ Set 1

1. ________ requires that only the first and second conditions of the RIP model are satisfied.
a) Weak mutation testing
b) Strong mutation testing
c) Weak test data
d) Strong test data

Answer

Answer: a [Reason:] Weak mutation testing is satisfied if only the reach and inspect stages of the RIP model is met.

2. Weak mutation is closely related to ______ methods.
a) Code Conduct
b) Code Coverage
c) Mutation Coverage
d) Mutation Redundancy

Answer

Answer: b [Reason:] Weak mutation checks for only two steps, searching for faults similar to those found by Code coverage methods.

3. ____ is a measure used to describe the degree to which the source code of a program is executed when a particular test suite runs.
a) Code Conduct
b) Code Coverage
c) Mutation Coverage
d) Mutation Redundancy

Answer

Answer: b [Reason:] Code coverage checks the percentage of the source code that is executed during testing by test data.

4. ___ is usually defined as a rule or requirement, which test suite needs to satisfy.
a) Code Conduct
b) Code Coverage
c) Coverage Criteria
d) Mutation Redundancy

Answer

Answer: c [Reason:] Coverage Criteria defines the rules or criteria which the test suites need to pass.

5. For the statement if( a || b) , which is not a mutant?
a) if(a && b)
b) if(a & b)
c) if( a | b)
d) if( a || b)

Answer

Answer: d [Reason:] The other three statements alter the original by changing the logical operator, hence introducing mutants.

6. Mutants which result in programs which are behaviourally equivalent to the original one are called ____-
a) Statement coverage
b) Condition coverage
c) Equivalent Mutants
d) Dead Mutants

Answer

Answer: c [Reason:] An equivalent mutant for the expression a=b+c would be a= b-(-c).

7. For the following function,

  1. int example (int x, int y)
  2. {
  3.     int z = 0;
  4.     if ((x>0) && (y>0))
  5.     {
  6.         z = x;
  7.     }
  8.     return z;
  9. }

Which function call ensure statement coverage for this function?
a) example(0,0)
b) example(1,0)
c) example(0,1)
d) example(1,1)

Answer

Answer: d [Reason:] The function call example(1,1) results in each statement of the function being executed leading to statement coverage.

8. For the following function,

  1. int example (int x, int y)
  2. {
  3.     int z = 0;
  4.     if ((x>0) && (y>0))
  5.     {
  6.         z = x;
  7.     }
  8.     return z;
  9. }

Which function call ensure function coverage for this function?
a) ex(1,2)
b) example(3,4)
c) example1(1,2)
d) etra(2,3)

Answer

Answer: b [Reason:] If during execution function ‘example’ is called at least once, then function coverage for this function is satisfied.

9. For the following function,

  1. int example (int x, int y)
  2. {
  3.     int z = 0;
  4.     if ((x>0) && (y>0))
  5.     {
  6.         z = x;
  7.     }
  8.     return z;
  9. }

Which function call ensure branch coverage for this function?
a) example(1,1)
b) example(0,1)
c) example(1,1) and example(0,1)
d) example(1,1) and example(1,1)

Answer

Answer: c [Reason:] In the first case, the two if conditions are met and z = x; is executed, while in the second case, the first condition (x>0) is not satisfied, which prevents executing z = x;

10. For the following function,

  1. int example (int x, int y)
  2. {
  3.     int z = 0;
  4.     if ((x>0) && (y>0))
  5.     {
  6.         z = x;
  7.     }
  8.     return z;
  9. }

Which function call ensures condition coverage for this function?
a) example(1,1)
b) example(0,1)
c) example(1,1) and example(0,1)
d) example(1,0) and example(0,1)

Answer

Answer: d [Reason:] These are necessary because in the first cases, (x>0) evaluates to true whereas in the second, it evaluates false. At the same time, the first case makes (y>0) false, whereas the second makes it true.

Java MCQ Set 2

1. Which is likely to benefit most from the use of test tools providing test capture and replay facilities?
a) Regression testing
b) Integration testing
c) System testing
d) User acceptance testing

Answer

Answer: a [Reason:] Regression testing benefits heavily from the usage of tools providing test capture and replay features.

2. While testing a product designed to mark exams, a tester determines that all scores between 90 to 100 yields a grade of A, but scores below 90 will not. This analysis is known as:
a) Boundary Value Analysis
b) Equivalence Partitioning
c) Positive Analysis
d) Negative Analysis

Answer

Answer: b [Reason:] The range is broken down and each range is tested. Hence, it is equivalence partitioning.

3. Which Life Cycle model has lesser, more or different levels of development and testing, all depending on the project and the software product?
a) Waterfall
b) Spiral
c) V shaped
d) Iterative

Answer

Answer: c [Reason:] The v shaped model may have component integration testing after component testing.

4. ________ is a partial measure of test thoroughness.
a) Boundary value testing
b) Equivalence Partitioning
c) DRE
d) Coverage measurement

Answer

Answer: d [Reason:] Coverage measurement checks the quality of test thoroughness.

5. _____ is an error condition hiding another error condition.
a) Masking
b) Fault Masking
c) Coverage measurement
d) Error Management

Answer

Answer: b [Reason:] Fault masking is a redundancy technique that completely masks faults.

6. COTS means _____
a) Cover Over The Source
b) Come Over The Standard
c) Commercial off The Shelf
d) Connecting Online Test Service

Answer

Answer: c [Reason:] Commercial-off-the-shelf (COTS) software and services are built and delivered usually from a third party vendor.

7. _______ is based on the project plan, but with greater amounts of detail.
a) Phase Test Plan
b) Review Plan
c) Review Document
d) Phase Design

Answer

Answer: a [Reason:] The phase test plan is based on the project plan which has a lot more detail than normal.

8. STLC stands for ________
a) Software Test Locale Code
b) Software Transfer Limited Code
c) Software Total Licence Control
d) Software Test Life Cycle

Answer

Answer: d [Reason:] The STLC or software test life cycle is the total life cycle of the testing phase of development.

9. During _____ testing, code is not executed.
a) Unit
b) Dynamic
c) Static
d) Equivalence

Answer

Answer: c [Reason:] Static testing does not require the code to be executed to test its components.

10. Static testing is done using the software ____
a) Documentation
b) Manual
c) Design
d) Comment

Answer

Answer: a [Reason:] Since static testing does not need code execution, software documentation is used to test.

Java MCQ Set 3

1. The JUnit hasItem() function is a _______
a) Hamcrest Matcher
b) Instance Function
c) JUnitMatcher
d) Matcher

Answer

Answer: c [Reason:] hasItem() is a useful matcher with for use with the assertThat method.

2. The package to which hasItem() function belongs is ___
a) org.junit.JUnitMatchers.hasItem
b) org.junit.hasItem
c) org.junit.Junit.hasItem
d) org.junit.hamcrest.hasItem

Answer

Answer: a [Reason:] The hasItem() is a JUnitMatcher.

3. Class JUnitMatchers extends ___
a) java.lang.Object
b) java.lang.String
c) java.util.*
d) java.util.Arrays

Answer

Answer: a [Reason:] JUnitMatchers manipulates the default Java objects and thus, extends java.lang.Object.

4. ___ is used for combining those matchers which must both pass.
a) all
b) both
c) justTwo
d) matchTwo

Answer

Answer: b [Reason:] The both function is a part of the internal Combinable matchers of JUnit.

5. ____ Hamcrest matcher tests for null values.
a) isNull
b) nullValue
c) isNullValue
d) isNullable

Answer

Answer: b [Reason:] The nullValue function is defined to detect null valued objects.

6. _____ tests whether a JavaBean has a particular property.
a) isProperty
b) porperty
c) hasProperty
d) isPresent

Answer

Answer: c [Reason:] The hasProperty is a core Hamcrest matcher.

7. To define a ________ in a JavaBean class, public getter and setter methods have to be supplied.
a) Class
b) Object
c) Value
d) Property

Answer

Answer: d [Reason:] Public setter and getter methods are required for Properties to be defined in JavaBeans classes.

8. A/An ____ property is an array instead of a single value.
a) Indexed
b) valued
c) null
d) variable

Answer

Answer: a [Reason:] In such cases, the bean class is responsible for providing methods for setting and getting everything.

9. ______ tests whether a given string equals another one, ignoring the case.
a) stringEqual
b) equalToIgnoringCase
c) ignoringCaseEqual
d) equalToCase

Answer

Answer: b [Reason:] equalToIgnoringCase is a core Hamcrest Matcher which tests given string equality.

10. ___ tests whether a given Map has a given entry.
a) hasItem
b) hasItems
c) hasValue
d) hasEntry

Answer

Answer: d [Reason:] Testing the map for a given entry can only be done using the hasEntry method.

Java MCQ Set 4

1. White box testing is also known as _______
a) Structure-based testing
b) Black box testing
c) Free testing
d) Closed testing

Answer

Answer: a [Reason:] Structure-based testing techniques use the internal structure of the software to derive test cases.

2. White box testing is ________
a) Static
b) Dynamic
c) Infeasible
d) Time-consuming

Answer

Answer: b [Reason:] White box testing tests the dynamic components of the code including their internal structure.

3. A _______ test is when an invalid input is put and errors are received.
a) Positive
b) Regression
c) Negative
d) Neutral

Answer

Answer: c [Reason:] Negative testing tests that invalid inputs do not get passed by the code.

4. A ______ test is when a valid input is put and some action to be completed in accordance with the specification is expected.
a) Positive
b) Regression
c) Negative
d) Neutral

Answer

Answer: a [Reason:] Positive testing checks that the correct output is produced for correct inputs.

5. Which tools is involved in the automation of regression test?
a) Data tester
b) Boundary tester
c) Capture/Playback
d) Output comparator.

Answer

Answer: d [Reason:] The Output comparator is a useful feature for seeing exactly what the error is in a test failure.

6. An input field takes the year as input between 1800 and 2016, the boundary values for testing this field are _____
a) 1899,1900,2004,2005
b) 1799,1900,2004,2005
c) 1799,1800,2016,2017
d) 1600,1700,1800,1900

Answer

Answer: c [Reason:] Only option (c) has the 4 boundary values for the given input range of 1800 to 2016.

7. Static analysis cannot ______
a) Enforce coding standards
b) Help in code understanding
c) Identify anomalies or defects in the code
d) Detect memory leaks

Answer

Answer: d [Reason:] Memory leaks occur dynamically and hence, static analysis cannot identify them.

8. ___ ensures the original fault has been removed.
a) Regression testing
b) Re-testing
c) Negative testing
d) Positive testing

Answer

Answer: b [Reason:] Regression testing looks for unexpected side effects while retesting ensures the original errors are removed.

9. _______ test cases are when random test cases are performed and equivalence partitioning is applied to those test cases.
a) Random
b) Static
c) Semi-random
d) Equivalent-random

Answer

Answer: c [Reason:] It removes redundant test cases, thus giving semi-random test cases.

10. ________ is normally used to evaluate a product to determine its suitability for intended use and to identify discrepancies.
a) Supervisor Review
b) Technical Review
c) Decision Review
d) Design Review

Answer

Answer: b [Reason:] Technical Review is often performed as a peer review without management participation.

Java MCQ Set 5

1. JUnit runners are available in which package?
a) org.junit.runners
b) junitfiles.runners
c) org.runners
d) org.junit.files.runners

Answer

Answer: a [Reason:] The default JUnit package is “org,junit”. Runners are found in “org,junit.runner”.

2. To start a test case as JUnit 3.8 test case which runner is required?
a) org.junit.runners.Junit4
b) org.junit.runners.Parameterized
c) org.junit.internal.runners.Junit38ClassRunner
d) org.junit.internal.runners.Junit4

Answer

Answer: c [Reason:] This runner is included in the current release of JUnit only for backward compatibility. It will start the test case as a JUnit 3.8 test case.

3. What is a Façade in JUnit?
a) It is a group of test cases
b) It is a design pattern that provides a unified interface to a set of interfaces in a subsystem
c) It is a collection of superclasses
d) It is a group of mock objects

Answer

Answer: b [Reason:] Façade defines a higher-level interface that makes the subsystem easier to use.

4. To create a custom test runner which class needs to be extended?
a) CustomRunner
b) TestRunner
c) Runner
d) UserRunner

Answer

Answer: c [Reason:] The Runner class is an abstract class that needs to be extended to create a custom test runner.

5. What type of object is returned on completion of a test?
a) org.junit.runner.Result
b) org.junit.runner.Complete
c) org.junit.runner.Outcome
d) org.junit.runner.Object

Answer

Answer: a [Reason:] An org.junit.runner.Result object collects and summarizes information from running multiple tests.

6. To listen to events during a test, which class has to be extended?
a) org.junit.runner.notification.RunListener
b) org.junit.runner.Listener
c) org.junit.runner.notification.Listener
d) org.junit.runner.RunListener

Answer

Answer: a [Reason:] To respond to events during a test run, RunListener is extended and the appropriate methods overridden. If a listener throws an exception during a test event, it is removed for the remainder of the test run.

7. When does the wasSuccessful() method of the Runner class return true?
a) The test file compiled
b) The test file ran
c) Some of the test cases ran successfully
d) All the test cases ran succesfully

Answer

Answer: d [Reason:] wasSuccesful() method is a public method of the Runner class that returns true if and only if all tests succeeded.

8. To run the file TestClass.class from the command line, we have to type what?
a) java TestClass
b) javac TestClass
c) java org.junit.runner.JUnitCore TestClass
d) org.junit.runner.JUnitCore TestClass

Answer

Answer: c [Reason:] The test cases are executed using JUnitCore class which is referenced by “org.junit.runner.JUnitCore”.

9. What does the getRunCount() method of the Result return?
a) String denoting the time of execution
b) Integer denoting the time of execution
c) int denoting the number of tests run
d) int denoting the number of failed tests

Answer

Answer: c [Reason:] getRunCount() returns the number of tests run. GetRuntime() returns the execution time in milliseconds.

10. What information does an object of the Failure class contain?
a) Description of the failed test
b) Description of the failed test and the exception thrown while running it
c) Description of the fail() method
d) Description of the exception thrown

Answer

Answer: b [Reason:] A failure contains an object of org.junit.runner.Description and the exception thrown while running the test case.

ed010d383e1f191bdb025d5985cc03fc?s=120&d=mm&r=g

DistPub Team

Distance Publisher (DistPub.com) provide project writing help from year 2007 and provide writing and editing help to hundreds student every year.