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 11 of 38

Q101.
What will be the output of the program?

boolean bool = true; 
if(bool = false) /* Line 2 */
{
    System.out.println("a"); 
} 
else if(bool) /* Line 6 */
{
    System.out.println("b"); 
} 
else if(!bool) /* Line 10 */
{
    System.out.println("c"); /* Line 12 */
} 
else 
{
    System.out.println("d"); 
}

a.

a

b.

b

c.

c

d.

d

Discuss
Answer: (c).c
Q102.
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 < 4; z++) 
        {
            switch (z) 
            {
                case x: System.out.print("0 ");
                default: System.out.print("def ");
                case x-1: System.out.print("1 ");  
                            break;
                case x-2: System.out.print("2 ");
            }
        }
    }
}
Discuss
Answer: (d).2 1 0 def 1 def 1
Q103.
What will be the output of the program?

int i = 0, j = 5; 
tp: for (;;) 
    {
        i++;  
        for (;;) 
        {
            if(i > --j) 
            {
                break tp; 
            } 
        } 
        System.out.println("i =" + i + ", j = " + j);
Discuss
Answer: (d).Compilation fails.
Q104.
Decrement operator '--' decreases the value of variable by what number?

a.

1

b.

2

c.

3

d.

4

Discuss
Answer: (a).1
Q105.
Evaluate the value of the expression?
     6 - 2 + 10 % 4 + 7
Discuss
Answer: (c).13
Q106.
What is/are highest order precedence operator(s) in Java?
Discuss
Answer: (c).both a and b
Discuss
Answer: (c).Combine two boolean values
Q108.
Which of the following is the correct expression that evaluates to true if the number x is between 1 and 100 or the number is negative?
Discuss
Answer: (b).((x < 100) && (x > 1)) || (x < 0)
Q109.
Select from among the following character escape code which is not available in Java.
Discuss
Answer: (c).\a
Q110.
What will be the output of the program?
class Main {
    public static void main(String [] args)
   {
     Main p = new Main();
     p.start();
   }
   void start()
   {
    long [] a1 = {3,4,5};
    long [] a2 = fix(a1);
 System.out.print(a1[0] + a1[1] + a1[2] + " ");
 System.out.println(a2[0] + a2[1] + a2[2]);
   }
   long [] fix(long [] a3)
   {
 a3[1] = 7;
 return a3;
   }
}
Discuss
Answer: (b).15 15

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!