143k views
1 vote
What is the output of the following code segment? t = 0; if(t > 7) System.out.print("AAA"); System.out.print("BBB"); BBB AAABBB AAA nothing

User Watery
by
4.6k points

1 Answer

2 votes

Answer:

BBB

Step-by-step explanation:

Given

Java code segment

Required

What is the output?

Analyzing the code segment 1 line after other

This line initializes t to 0

t = 0;

This line checks if t is greater than 7

if(t > 7)

If the above condition is true, the next line is executed

System.out.print("AAA");

NB: Since t is not greater than 7, System.out.print("AAA"); will not be executed

Lastly, this line executed

System.out.print("BBB");

Hence, BBB will be displayed as output

User Ian Dunn
by
3.6k points