top of page
ICSE Class 9 Computer Applications
5. Input in java
 
       01  By initialisation
​

                           data before execution - e.g. int a=5;

​

​

 02   By function parameter

             at the time of execution - e.g. void display(int a, int b)

 

                 

03   By input stream

          data entry during execution (Scanner class) (Introduction of package :util)

​                 

​

04   Scanner class methods

​

​                 The Scanner class of the java.util package

                 is used to read input data from different sources like input streams, users, files, etc.


                 we need to import the java.util.Scanner package before we can use the Scanner class.

                 Method                          Description
                 nextInt()                      reads an int value from the user

                 nextFloat()                  reads a float value from the user

                 nextBoolean()             reads a boolean value from the user

                 nextLine()                   reads a line of text from the user

                 next()                          reads a word from the user

                 nextByte()                   readsa byte value from the user

                 nextDouble()              reads a double value from the user

                 nextShort()                 reads a short value from the user

                 nextLong()                 reads a long value from the user

​
 

                 

05   Types of errors

​                 

                         • Syntax Error: Syntax of the language is not respected.

                         Egs: Missing semi-colon etc.

                         int a=5

​

                         •Semantic Error: Improper use of program statements.

                         Egs. Type incompatibility etc.

                         int s=“hello”;

​

                        •Logical Error: Specification is not respected.

                        Egs. Errors in performed computation.

                        c=a+b; (Use of + instead of -)

​

06   Types of comments

​                 Comments                      is an explanatory text


                 Types of comments        single line ( // ) used for commenting a single line

                                                         multiline (/*… */) used for commenting a multiple line

​​

Anchor 3
Anchor 4
Anchor 2
Anchor 1
Anchor 5
Anchor 6
bottom of page