Page 102 - computer science (868) class 11
P. 102
9 {
10 System.out.println("Enter 2 numbers : ");
11 a=sc.nextInt();
12 b=sc.nextInt();
13 s=a+b;
14 System.out.println("The result is : "+s);
15 }
16 catch(Exception ex)
17 {
18 System.out.println("You are supposed to enter an integer value");
19 }
20 }
21 }
The output of the preceding program is as follows: (If taken a double value)
Let’s Revisit
♦ The concepts of class and object are obtained by programs written using object-oriented programming languages such as
Java, C++, etc.
♦ An object is a unique entity that contains properties, methods and events in an object-oriented programming language.
♦ Classes in Java are non-primitive data types that act as a blueprint for creating objects of the same type.
♦ The occurrence of a class that contains characteristics and behaviour of the same class is called an object. In other words,
objects are the instances of a class.
♦ A user-defined data type is a derived data type depending on some existing data types.
♦ A Virtual Machine (VM) uses software instead of a physical computer to execute programs and install apps.
♦ During the execution of a program, an error may occur which may stop the execution of the program. This error is known as an
exception.
♦ Exception handling is a mechanism to handle errors that occur during the execution of the program so that the normal flow of
the code can be maintained.
♦ A “finally” keyword follows after the try block. It always executes whether there is an exception or not. It appears at the end of
the catch block.
♦ Input/Output exceptions (I/O) are Java IOExceptions that occur whenever an input or output operation is unsuccessful or
interpreted.
100100 Touchpad Computer Science-XI

