Java find output programs
- Java find output programs (Data Types) | set 1
- Java find output programs (Data Types) | set 2
- Java find output programs (Data Types) | set 3
- Java find output programs (Operators) | set 1
- Java find output programs (Operators) | set 2
- Java find output programs (Operators) | set 3
- Java find output programs (if else) | set 1
- Java find output programs (if else) | set 3
- Java find output programs (switch case) | set 1
- Java find output programs (switch case) | set 2
- Java find output programs (switch case) | set 3
- Java find output programs (Loops) | set 1
- Java find output programs (Loops) | set 2
- Java find output programs (Loops) | set 3
- Java find output programs (Arrays) | set 1
- Java find output programs (Arrays) | set 2
- Java find output programs (Arrays) | set 3
- Java find output programs (this Keyword) | set 1
- Java find output programs (final Keyword) | set 1
- Java find output programs (final Keyword) | set 2
- Java find output programs (static Keyword) | set 1
- Java find output programs (static Keyword) | set 2
- Java find output programs (Parameter Passing) | set 1
- Java find output programs (Class and Objects) | set 1
- Java find output programs (Class and Objects) | set 2
- Java find output programs (Class and Objects) | set 3
- Java find output programs (Constructor & Destructor) | set 1
- Java find output programs (Constructor & Destructor) | set 2
- Java find output programs (Constructor & Destructor) | set 3
- Java find output programs (Inheritance) | set 1
- Java find output programs (Inheritance) | set 2
- Java find output programs (Inheritance) | set 3
- Java find output programs (Interface) | set 1
- Java find output programs (Interface) | set 2
- Java find output programs (Interface) | set 3
- Java find output programs (Overloading) | set 1
- Java find output programs (Overloading) | set 2
- Java find output programs (Overriding) | set 1
- Java find output programs (Overriding) | set 2
- Java find output programs (Overriding) | set 3
- Java find output programs (Exception Handling) | set 1
- Java find output programs (Exception Handling) | set 2
- Java find output programs (Exception Handling) | set 3
- Java find output programs (Enumeration) | set 1
- Java find output programs (Enumeration) | set 2
- Java find output programs (Autoboxing & Unboxing) | set 1
- Java find output programs (Autoboxing & Unboxing) | set 2
- Find output programs (Java String class)
- Find Output of Java program - 1 (Mixed topics)
- Find Output of Java program - 2 (Mixed topics)
- Java find output programs (if else) | set 2
Answer Question 1:
Output:
Explanation:
In the above program, we did not use condition in the for loop, if we do not use loop condition in the for loop, then the condition will be considered as true in Java, that's why it will print "India" infinite times on the console screen.
Answer Question 2:
Output:
Explanation:
The above program will generate syntax error because we cannot use the while loop without condition in Java.
Answer Question 3:
Output:
Explanation:
The above program will generate syntax error because of missed semicolon after loop condition. The correct code is given below:
do { System.out.println(num*val); }while(val<=10);
Answer Question 4:
Output:
Explanation:
In the above program, we created a variable loop using var, in the Java we cannot use var type to declare a variable. That's why the compilation error will be generated by the above program.
Answer Question 5:
Output:
Explanation:
In the above program, we created two local variables Val and loop initialized with 1235 and 0 respectively.
Now look to the iteration,
Iteration1: Val=1235, loop=0 condition is true. Val = val/10; Val = 1235/10; Val = 123; And loop will 1. Iteration2: Val=123, loop=1 condition is true. Val = val/10; Val = 123/10; Val = 12; And loop will 2. Iteration3: Val=12, loop=2 condition is true. Val = val/10; Val = 12/10; Val = 1; And loop will 3. Iteration4: Val=1, loop=3 condition is true. Val = val/10; Val = 1/10; Val = 0; And loop will 4. And condition is false because the value of variable 'val' is not greater than 0 Then we value of "val" will be printed on the console screen.
need an explanation for this answer? contact us directly to get an explanation for this answer