Page 219 - Computer science 868 Class 12
P. 219

System.out.print(p);
                        Output is …………………
                    3.  What is the output of the following code?

                       String subject = "Computer";
                       int marks = (subject == "Computer")?10:20;
                       System.out.println("Marks=" + marks);
                        Output  is …………………
                    4.  Give the output of the following program segment.

                       int x=0;
                        do
                        {    if(x<3)
                          {
                             x+=2;
                             System.out.println(x);
                             continue;
                        }
                        else
                        {
                             System.out.println(++x);
                             break;
                           }
                        }
                        while(x<10);
                        Output is …………………
                    5.  What is the output of the following code snippet?
                       int a = 25, b=33;
                       String name = true?"CAT":"DOG";
                       System.out.println(name);
                        Output is …………………
                    6.  What is the output of the following code?
                         int a=10, b=4, c=0;

                       if(c==0)
                       {
                             c=a++ + ++b;
                       System.out.println(c);
                       }
                        Output is …………………
                    7.  ………………… is required to send the control to the next iteration of the loop.
                    8.  Find the output
                       System.out.println((4>5)?5-4:4-2);
                        Output is …………………
                    9.  What is the output of the Java program?
                       int a=10;
                       if(a==9)
                       { System.out.println("OK ");
                         System.out.println("MASTER"); }
                       else
                         System.out.println("BYE");
                        Output  is …………………
                    10.  The break statement is used along with loop and ………………… .



                                                                                                                       217
                                                                                                 Statements and Scope  217
   214   215   216   217   218   219   220   221   222   223   224