Looping Statements

Q: What will be the output of the given code?
public class Main {
    public static void main(String args[]) 
    {
       int i = 0; 
        for (System.out.print("Neowise"); i < 1; i++) 
            System.out.print("Neostark");  
    }
}
A: NeowiseNeostark
Q: In the given code, how many times is "Hello" will be printed?
public class Main {
    public static void main(String[] args)
    {
        for(int i = 0; i>5; )
        {
            System.out.println("Hello");
        }
    }
}
A: No output
Q: Predict the output for the following code:
import java.util.Scanner;
public class Main
{
    public static void main(String args[]) 
    {
         for (int i = 0, String = "GFG"; i < 2; i++) 
            System.out.println(“SuperMan"); 
    }
}
A: Compilation error
Q: What will be the output of the given code?
public class Main {
    public static void main(String[] args)
    {
        String s = "friends";
        int x = 0;
        do 
        {
            System.out.print(s.charAt(x));
            x++ ;
        } 
        while (x < 2);
    }
}
A: fr
Q: How many times is "main" printed?
public class Main
{
    public static void main(String[] args) 
    {
	    while(true)
	    {
	        System.out.println("main");
	    }
    }
}
A: Infinite times
Q: What will be the output of the following program?
class Main {
    public static void main(String args[]) {
		int x = 2;
		int y = 0;
		for ( ; y < 10; ++y) 
		{
			if (y % x == 0) 
			   continue;  
			else if (y == 8)
			   break;
			else
			   System.out.print(y + " ");
		}
    }
}
A: 1 3 5 7 9 
Q: How often is the word "Hello" printed?
public class Main
{
    public static void main(String[] args)
    {
        for(int i = 0; i<5; i++)
        {
            System.out.println("Hello");
            i++;
        }
    }
}
A: 3
Q: In the following code, how many times is "Hello" printed?
public class Main
{
    public static void main(String[] args)
    {
        for(int i = 0; i<5; i++)
        {
            System.out.println("Hello");
            i++;
            i--;
        }
    }
}
A: 5
Q: How many times does "Hello" appear?
public class Main 
{
    public static void main(String[] args)
    {
        for(int i = 0; i<5; i=5 )
        {
            System.out.println("Hello");
        }
    }
}
A: 1
Q: How many times did you print "coding"?
public class Main
{
    public static void main(String[] args) 
    {
	    while(true);
	    {
            System.out.println("coding");
	    }
    }
}
A: Error: unreachable statement
Q: What will the output of the given code be?
public class Main 
{
	public static void main(String[] args) 
	{
	    int i = 0;
        while (i == 0)
        System.out.println("True\n");
        System.out.println("False\n");
	}
}
A: True Infinite times
Q: How many times is the "Hello" word printed?
public class Main
{
    public static void main(String[] args)
    {
        for(int i = 0; i<5; i++)
        {
            System.out.println("Hello");
            i+=2;
        }
    }
}
A: 2
Q: How many times is "Good Day" printed?
public class Main
{
    public static void main(String[] args) 
    {
        while(true)
        {
            System.out.println("GoodDay");
            break;
        }
    }
}
A: 1
Q: In the following code, how many times is the word "hello" printed?
public class Main
{
    public static void main(String[] args)
    {
        for(int i = 0; i<5; i++)
        {
        System.out.println("hello");
        break;
        }
    }
}
A: 1
Q: How many times is "Hello" printed?
public class Main
{
    public static void main(String[] args) 
    {
	    while(false)
	    {
	        System.out.println("hello");
	    }
    }
}
A: Error: Unreachable Statement