Write a Java program segment to print an inverted right-angled triangle of stars with n rows, the first row having n stars.
Nested Loops
Original Khojo Papers practice question — not from a past board paper.
for (int i = 1; i <= n; i++) { for (int j = 1; j <= i; j++) System.out.print("*"); System.out.println(); }
No citable source has been recorded for this record. Treat it as practice material, not as fact.
The outer loop controls the rows and the inner loop the number of stars in each, which is why the inner limit depends on i.
From the same topic and chapter, at a similar level.
Write a Java program segment to print an inverted right-angled triangle of stars with n rows, the first row having n stars.
Nested Loops
How many times does the inner statement execute in: for (int i = 1; i <= 4; i++) for (int j = 1; j <= 3; j++) count++;
Nested Loops
Write a Java program segment to print the multiplication tables from 1 to 5, each up to 10.
Nested Loops
What is the output of: String s = "Examination"; System.out.println(s.length() + " " + s.substring(0, 4) + " " + s.toUpperCase().charAt(2));
String Handling
Explain the ternary operator in Java and rewrite "if (a > b) max = a; else max = b;" using it.
Operators and Expressions in Java
Reduce the Boolean expression X·Y + X·Y′ using the laws of Boolean algebra.
Boolean Algebra