CS FundamentalsHardProduct-company MCQ pattern
For the code `if (x > 0) { y = 1; }` followed by `print(y)`, a single test with x = 5 is run. What coverage does it achieve?
- A. 100% statement and 100% branch coverage
- B. 50% statement coverage and 50% branch coverage
- C. 100% statement coverage but only 50% branch coverage
- D. 50% statement coverage and 100% branch coverage
Correct answer: C. 100% statement coverage but only 50% branch coverage
x = 5 executes every statement, but only the true outcome of the if is taken; the false outcome (x ≤ 0) is never exercised, so 1 of 2 branches = 50%. Branch coverage is the stronger criterion.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- A server has a mean time between failures of 990 hours and a mean time to repair of 10 hours. What is its availability?
- A new build arrives and testers first run a small, broad set of checks (does it install, launch, log in, open the main screens?) before…
- You are halfway through a change when an urgent bug needs fixing on the same branch. Which command shelves your uncommitted changes so the…
- A Dockerfile ends with CMD ["python", "app.py"]. The container is started with docker run myimage python test.py. What runs?
- Which practice is the defining feature of Kanban rather than Scrum?
- Java's I/O library lets you write new BufferedReader(new InputStreamReader(socket.getInputStream())), each wrapper adding behaviour to the…