Page 72 - TP_iPlus_V2.1_Class8
P. 72

D.  Find the errors in the following Java codes:
                      1.  public class program{
                               public static void main(String[] args){
                                       int a = 10;
                                       int b = 20
                                       int c = a + b;
                                       System.out.println("The value of c is: "+c);
                               }
                             }
                      2.  public class assignment{
                               public static void main(String[] args){
                                       int a ==10;
                                       System.out.println(a);
                               }
                             }
                      3.  public class D3{
                               public static void main(String[] args){
                               int a = 5;
                               String name = "Chirag";
                               System.out.println(a + name);
                             }
                      4.  public class D4{
                               public static void main(String[] args){
                               System.out("Welcome");
                             }}
                  E.  Competency-based/Application-based questions:

                      1.   Anil wants to increase the value of the variable a by 1 and assigns the value
                         again to the variable a. Which Java operator can help him do this?
                      2.   Naveen wants to display his name on the screen. Which data type of Java can help
                         him do this?

                                                                                        #Coding & Computational Thinking
                  Higher Order Thinking Skills (HOTS)
                  1.   Rakshit has written a java code for, but he is getting errors on execution. Identify the error and rewrite
                     the code.
                    public class Simple{

                    public static void main(String[] args){
                    system.out.println("Hello Java");
                    }
                    }
                  2.  Ajay is assigning variable “Address” value “Delhi” by writing
                    Address == “Delhi”
                     Also to check value of Address if it is Delhi or not by writing

                    Address = “Delhi” .
                     How is “=” different from “==” and is he writing the correct statements? Explain



                    70
                         iPlus (Ver. 2.1)-VIII
   67   68   69   70   71   72   73   74   75   76   77