When does a syntax error occur?
Syntax errors occur when a mistake is made in the language rules or sentence structure of the programming language.
Can a program run with a logical error?
Yes, the program can run, but it may give wrong or unexpected results.
Is a runtime error the same as a syntax error?
No, a syntax error occurs when the code is written incorrectly, while a runtime error happens when the program is running.
What does testing ensure in software development?
Testing ensures that the software behaves as expected, is reliable, and meets user requirements.
Why is Stability important in software, and what does it ensure?
Stability ensures that if an error occurs, it does not cause serious or irreversible damage to the software, maintaining the system's robustness.
What are some very common mistakes that lead to syntax errors?
Missing Semicolons, Misspelled Keywords, Mismatched Parentheses
Can changing variable values help fix a logical error?
Yes, adjusting variable values or how they are used in the program can fix a logical error, especially if they’re involved in wrong calculations or conditions.
What causes a runtime error?
Common causes include dividing by zero, accessing invalid memory, or using incorrect input.
public class Main {
public static void main(String[] args) {
int num = 5;
if (num > 0)
System.out.println("Positive number")
else
System.out.println("Non-positive number");
}
}
public class Main {
public static void main(String[] args) {
int num = 5;
if (num > 0) {
System.out.println("Positive number");
} else {
System.out.println("Non-positive number");
}
}
}
What does the quality attribute "Reliability" refer to in software testing?
Reliability is the likelihood that the software will run without crashing under certain conditions for a specified period.
What is a syntax error, and how does it differ from a logical error?
A syntax error breaks the code structure; a logical error runs but gives wrong results,
Is testing the program enough to find logical errors?
No, while testing helps, careful code review and debugging are also necessary to find and fix logical errors.
Can runtime errors be detected before the program runs?
No, runtime errors happen while the program is running, so they can’t be detected during the coding phase.
What are the steps of testing?
Step 1. Creating a set of test cases
Step 2. Running the program with each test case
Step 3. Checking that the performance of the software is as expected.
How should software handle input and output to ensure good Usability?
To ensure good Usability, the software should allow flexible user input and produce output that is clear, well-structured, and easy to interpret.
How can extra or missing brackets cause a syntax error?
It breaks the code’s structure, leading to confusion for the compiler.
How can incorrect calculations happen due to a logical error?
A logical error in the code can lead to incorrect operations or wrong conditions, causing the program to calculate the wrong result.
What is a runtime error?
A runtime error occurs when a program crashes or behaves unexpectedly while it’s running.
public class AverageCalculator {
public static void main(String[] args) {
int num1 = 10;
int num2 = 20;
int num3 = 30;
int sum = num1 + num2;
int average = sum / 3;
System.out.println("The average is: " + average);
}
}
public class AverageCalculator {
public static void main(String[] args) {
int num1 = 10;
int num2 = 20;
int num3 = 30;
int sum = num1 + num2 + num3;
int average = sum / 3;
System.out.println("The average is: " + average);
}
}
How is Maintainability defined as a quality attribute in software?
Maintainability is how easily the software can be debugged, updated, or expanded without causing additional issues.
What happens if you forget a semicolon at the end of a statement in languages like Java or C?
It causes a syntax error, as the compiler expects it.
Can you identify a logical error by looking at the program’s output?
Yes, logical errors often produce incorrect or unexpected results, which can help identify them.
What is a "division by zero" error?
This happens when the program tries to divide a number by zero, which is mathematically undefined and causes the program to crash.
Why is debugging essential in software development?
Debugging ensures that software is reliable, efficient, and functions correctly.
How does Portability affect a software’s ability to run on different systems?
Portability allows software to be easily adapted for different systems, enhancing its compatibility with various devices and operating systems.