Page 69 - iprime_V2.2_class8
P. 69

C.  What will be the output of these Java codes?

                    1.  public class rad{
                                                                                 Write output here:
                           public static void main(String[] args){

                               double r, c;
                               r=2.3;
                               c = 2 * 3.14 * r;

                               System.out.println(c);
                           }
                        }

                    2.  public class A {
                           public static void main(String[] args)                Write output here:
                           {

                               double s, GST, inv;
                               s = 200;
                               GST = 5 * s/100;
                               inv = s + GST;

                               System.out.println("GST to be paid:" + GST);
                               System.out.println("Total invoice value:" + inv);
                            }
                        }

                    3.  public class program{
                           public static void main(String[] args){                Write output here:
                               int a, b, c;

                               a = 10;
                               b = 20;
                               c = a;
                               a = b;

                               b = c;
                               System.out.println("Value of a is:" + a);
                               System.out.println("Value of b is:" + b);
                           }

                        }
                                                                                 Write output here:
                    4.  public class A1{
                           public static void main(String[] args){
                           String first_name = "Kittu";

                           String last_name = "Sharma";
                           String name = first_name + " " +  last_name;



                                                                                               Program Coding      67
   64   65   66   67   68   69   70   71   72   73   74