NPTEL Software Testing Week 6 Assignment Answers 2024

By Sanket

NPTEL Software Testing Week 6 Assignment Answers 2024

1. Typically, how do logical constraints occur in pre-conditions and postconditions that specify assumptions on inputs to methods or describe the properties of the methods?

• The logical conditions can be any logical predicate.
• The logical conditions occur in conjunctive or disjunctive normal form.
• The logical conditions are a simple OR or AND combinations of two or more clauses.
• The logical conditions always describe what the methods should not process as inputs.
`Answer :- For Answers Click Here `

2. State true or false: It is desired that a logical predicate used in a decision statement be a tautology.

• True.
• False.
`Answer :- For Answers Click Here `

3. How do logical predicates occur in finite state machines?

• They occur as guards in the transitions of a finite state machine.
• They occur as predicates in the states of a finite state machine.
• They occur in the actions labeling the transitions of a finite state machine.
• They occur in the events of a finite state machine.
`Answer :- For Answers Click Here `

4. State true or false: The logical predicates occuring in the condition statements of a method are all simple propositional logic formulas.

• True.
• False
`Answer :- `

Consider the following code that has two conditional statements and the corresponding two logical predicates. Answer the following questions with reference to logical coverage criteria on this code.

``````import java.util.Scanner;
class Sum_Odd_Number
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.print("Enter The Number of Limit : ");
int l =input.nextInt();
int sum = 0;
for(int s=1;s<=l;s++)
{
if(s%2==1)
sum = sum + s;
}
System.out.println("Sum of Odd Numbers :"+sum);
}
}``````

5. Which of the options below best describe what the above program computes?

• It computes the sum of all the numbers up to the limit l.
• It computes the sum of all the even numbers up to the limit l.
• It computes the sum of all the odd numbers up to the limit l.
• It computes the number of odd numbers up to the limit l.
`Answer :- `

6. How many clauses are there in the above program, per predicate?

• There are two predicates, each having one clause.
• There are two clauses in the program, to be considered as a part of the second predicate.
• There are four clauses in the program, two per predicate.
• There are l different clauses in the program, one for each iteration of the loop.
`Answer :- For Answers Click Here `

7. What does predicate coverage test for the second clause in the above program?

• It tests for the number being odd or even.
• It tests for the number being within or outside the limit.
`Answer :- `

8. What does the test case for predicate coverage evaluating to true for the first predicate mean in the above program?

• The first predicate evaluating to true indicates repeated iterations of the for loop.
• The first predicate evaluating to true indicates exit from the for loop.
`Answer :- `

9. State true or false: Clause coverage and predicate coverage are the same for both the predicates in the above program?

• True.
• False.
`Answer :- `

10. In the ith iteration of the for loop, which of the following represents the actual predicate corresponding to the if statement?

• The predicate in the ith iteration is s%2 == 1.
• The predicate in the ith iteration is (1 + i)%2 == 1.
• The predicate in the ith iteration is i%2 == 1.
• The predicate in the ith iteration is 1%2 == 1.
`Answer :- For Answers Click Here `