Question 1041
int age = 25;
if (age >= 18 && age < 65)
{
System.out.print("adult ");
}
if (age < 18 || age >= 65)
{
System.out.print("special ");
}
if (!(age >= 18) || !(age < 65))
{
System.out.print("edge ");
}
What is printed when the code segment executes?Main Solution
Answer
Answer: B. With age = 25: first condition 25 >= 18 && 25 < 65 is true — prints "adult ". Second: 25 < 18 || 25 >= 65 is false. Third: the condition !(25 >= 18) || !(25 < 65) is !true || !true = false. Only "adult " prints.
Answer: Correct: B
Answer images

