adplus-dvertising

Welcome to the Operators and Control Statements MCQs Page

Dive deep into the fascinating world of Operators and Control Statements with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Operators and Control Statements, a crucial aspect of Java Programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Operators and Control Statements, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Java Programming.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Operators and Control Statements. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Java Programming.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Operators and Control Statements. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Operators and Control Statements MCQs | Page 10 of 38

Explore more Topics under Java Programming

Q91.
What will be the output of the program?

Float f = new Float("12"); 
switch (f) 
{
    case 12: System.out.println("Twelve"); 
    case 0: System.out.println("Zero"); 
    default: System.out.println("Default"); 
}
Discuss
Answer: (d).Compilation fails
Q92.
What will be the output of the program?

int i = 0; 
while(1) 
{
    if(i == 4) 
    {
        break;
    } 
    ++i; 
} 
System.out.println("i = " + i);
Discuss
Answer: (d).Compilation fails.
Q93.
What will be the output of the program?

public class Delta 
{ 
    static boolean foo(char c) 
    {
        System.out.print(c); 
        return true; 
    } 
    public static void main( String[] argv ) 
    {
        int i = 0; 
        for (foo('A'); foo('B') && (i < 2); foo('C')) 
        {
            i++; 
            foo('D'); 
        } 
    } 
}
Discuss
Answer: (a).ABDCBDCB
Q94.
What will be the output of the program?

public class Switch2 
{
    final static short x = 2;
    public static int y = 0;
    public static void main(String [] args) 
    {
        for (int z=0; z < 3; z++) 
        {
            switch (z) 
            {
                case y: System.out.print("0 ");   /* Line 11 */
                case x-1: System.out.print("1 "); /* Line 12 */
                case x: System.out.print("2 ");   /* Line 13 */
            }
        }
    }
}
Discuss
Answer: (c).Compilation fails at line 11.
Q95.
What will be the output of the program?

public class If1 
{
    static boolean b;
    public static void main(String [] args) 
    {
        short hand = 42;
        if ( hand < 50 && !b ) /* Line 7 */
            hand++;
        if ( hand > 50 );     /* Line 9 */
        else if ( hand > 40 ) 
        {
            hand += 7;
            hand++;    
        }
        else
            --hand;
        System.out.println(hand);
    }
}
Discuss
Answer: (d).51
Q96.
What will be the output of the program?

public class Test 
{
    public static void main(String [] args) 
    {
        int I = 1;
        do while ( I < 1 )
        System.out.print("I is " + I);
        while ( I > 1 ) ;
    }
}
Discuss
Answer: (c).No output is produced.
Q97.
What will be the output of the program?

int x = l, y = 6; 
while (y--) 
{
    x++; 
} 
System.out.println("x = " + x +" y = " + y);
Discuss
Answer: (d).Compilation fails.
Q98.
What will be the output of the program?

int I = 0;
    outer:
    while (true) 
    {
        I++;
        inner:
        for (int j = 0; j < 10; j++) 
        {
            I += j;
            if (j == 3)
                continue inner;
            break outer;
        }
        continue outer;
    }
System.out.println(I);

a.

1

b.

2

c.

3

d.

4

Discuss
Answer: (a).1
Q99.
What will be the output of the program?

for(int i = 0; i < 3; i++) 
{ 
    switch(i) 
    { 
        case 0: break; 
        case 1: System.out.print("one "); 
        case 2: System.out.print("two "); 
        case 3: System.out.print("three "); 
    } 
} 
System.out.println("done");
Discuss
Answer: (d).one two three two three done
Q100.
What will be the output of the program?

public class Test 
{  
    public static void main(String args[]) 
    { 
        int i = 1, j = 0; 
        switch(i) 
        { 
            case 2: j += 6; 
            case 4: j += 1; 
            default: j += 2; 
            case 0: j += 4; 
        } 
        System.out.println("j = " + j); 
    } 
}
Discuss
Answer: (d).j = 6

Suggested Topics

Are you eager to expand your knowledge beyond Java Programming? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!