6. 

What will be the output of the program?

int i = (int) Math.random();

A. i = 0
B. i = 1
C. value of i is undetermined
D. Statement causes a compile error

7. 

What will be the output of the program?

int i = 1, j = 10; 
do 
{
    if(i++ > --j) /* Line 4 */
    {
        continue; 
    } 
} while (i < 5); 
System.out.println("i = " + i + "and j = " + j); /* Line 9 */

A. i = 6 and j = 5
B. i = 5 and j = 5
C. i = 6 and j = 6
D. i = 5 and j = 6

8. 

What will be the output of the program?

class Q207 
{ 
    public static void main(String[] args) 
    {
        int i1 = 5; 
        int i2 = 6; 
        String s1 = "7"; 
        System.out.println(i1 + i2 + s1); /* Line 8 */
    } 
}

A. 18
B. 117
C. 567
D. Compiler error

9. 

What will be the output of the program?

interface Foo141 
{ 
    int k = 0; /* Line 3 */
} 
public class Test141 implements Foo141 
{
    public static void main(String args[]) 
    {
        int i; 
        Test141 test141 = new Test141(); 
        i = test141.k; /* Line 11 */
        i = Test141.k; 
        i = Foo141.k; 
    } 
}

A. Compilation fails.
B. Compiles and runs ok.
C. Compiles but throws an Exception at runtime.
D. Compiles but throws a RuntimeException at runtime.

10. 

What will be the output of the program?

String a = "newspaper";
a = a.substring(5,7);
char b = a.charAt(1);
a = a + b;
System.out.println(a);

A. apa
B. app
C. apea
D. apep