ICSE Class-10 Computer Application Revision Notes
ICSE Class-10 Computer Application Revision Notes
Revision Notes
In Object Oriented Programming (OOP), the data and its methods are enclosed in a class.
The basic concepts of OOP include Data Abstraction, Encapsulation, Inheritance, Polymorphism and Modularity.
Java is an Object Oriented Programming Language that has the Object-Oriented features. It supports the
following features:
Polymorphism: It is a capability of a method to do different things based on the object that it is acting upon.
Inheritance: A mechanism in which one class acquires all the properties and behaviours of parent class.
Encapsulation: A process of wrapping Data and Function together into a single unit i.e., class.
Abstraction: It is a process of hiding the implementation details and showing only essential information to
the user.
Object: Objects have states and behaviours. Example: A dog has states - colour, name, breed as well as behaviours
like - wagging the tail, barking, eating etc. An object is an instance of a class.
Class : A class can be defined as a template/blueprint that describes the attributes and behaviours of a set of
objects.
Method : A method is a collection of statements that are grouped together to perform the specified task.
Variable : It is a container which holds the value while the Java program is executed. A variable is assigned with
a datatype. There are three types of variables in Java:
(i) Local variables : Variables which are defined inside methods, constructors or blocks are called local variables.
The variable will be declared and initialized within the method and the variable will be destroyed when the
method has completed.
(ii) Instance variables : Instance variables are variables which are defined within a class but outside any method.
These variables are initialized when the class is instantiated. Instance variables can be accessed inside any
method, constructor or blocks of that particular class.
(iii) Static variables : Static variables are variables declared within a class, outside any method, with the static
keyword. All the objects of a class will share the same copy of static variable. If the value of a static variable
will be updated for one object, the same changes will be reflected for all the other objects.
Data Types in Java: Data types specify the different sizes and values that can be stored in the variable.
Data Type
Primitive Non-
Primitive
Integer Floating
char point
byte float
short double
int
long
2 Oswaal ICSE Revision Notes Chapterwise & Topicwise, COMPUTER APPLICATION, Class-X
‘do-while’ loop : It is very similar to the ‘while’ loop shown above. The only difference being, in a ‘while’loop
is that the condition is checked before the body of loop, but in a ‘do-while’ loop, the
condition is checked after one execution of the loop.
Syntax: do
{
statements
}while (condition);
‘for’ loop: It is the most used loop in Java. The syntax is slightly more complicated than that of ‘while’
or the ‘do-while’ loop.
Syntax: for(<initial value>;<condition>;<increment/decrement>){
statements.}
break Statement: Use the break statement to terminate a loop, switch, or in conjunction with a labelled statement.
(i) When you use break without a label, it terminates the innermost enclosing while, do-while, for, or switch
immediately and transfers control to the following statement.
(ii) When you use break with a label, it terminates the specified labelled statement.
Syntax: break [Label]
continue Statement: The continue statement can be used to restart a while, do-while, for or label statement.
(i) When you use continue without a label, it terminates the current iteration of the innermost enclosing
while,do-while, or for statement and continues execution of the loop with the next iteration. In contrast to
the break statement, continue does not terminate the execution of the loop entirely. In a while loop, it jumps
back to the condition. In a for loop, it jumps to the increment-expression.
(ii) When you use continue with a label, it applies to the looping statement identified with that label.
Syntax: continue [Label];
Nested for Loop: Nested for loop are used to execute a loop inside another loop.
Syntax: for (initialization; condition; increment/decrement)
{
statement
for (initialization; condition; increment/decrement)
{
statement
}
}
Key Words
AWT: Abstract Window Toolkit
JVM: Java Virtual Machine
JIT: Just In Time
JDT: Java Development Toolkit
API: Application Programming Interface
CHAPTER-2
CLASS AS THE BASIS OF ALL COMPUTATION
Revision Notes
double
double datatype is a double-precision 64-bit IEEE 754 floating point.
This datatype is generally used as the default datatype for decimal values, generally the default choice.
double datatype should never be used for precise values such as currency.
Example, double d1 = 123.4.
Boolean
boolean datatype represents one bit of information.
There are only two possible values: true and false.
This datatype is used for simple flags that track true/false conditions.
Example, boolean one = true.
char
char datatype is a single 16-bit Unicode character.
Minimum value is ‘\u0000’ (or 0) and maximum value is ‘\uffff ’ (or 65,535 inclusive).
char datatype is used to store any character.
Example, char letterA = ‘A’.
Reference Datatypes
Reference variables are created using defined constructors of the classes. They are used to access objects.
These variables are declared to be of a specific type that cannot be changed. For example, Employee, Puppy,
etc.
Class objects and various types of array variables come under reference data-type.
Default value of any reference variable is null.
A reference variable can be used to refer any object of the declared type or any compatible type.
Key Words
Class: A class is a blueprint that represents a set of similar objects having a common structure and behaviour.
Object: It is an identifiable identity with some characteristics or state and behaviour.
Glossary
Byte Code: Java portable code
Applet: Small Java Program
Bean: Java Software
Void: Null Value
Template: Generic Class
CHAPTER-3
USER-DEFINED METHODS
Revision Notes
Method/function: A method is a block of code which is used at different instances in the program.
Need of methods:
To allow us to handle complex problems.
To hide low-level details that are ambiguous and confuse.
To reuse portions of code without retyping it.
Help in easier debugging of code.
Syntax of methods:
<Access specifier><Return type><method name> (parameter list)
{• //Body of the method•}
Oswaal ICSE Revision Notes Chapterwise & Topicwise, COMPUTER APPLICATION, Class-X 7
(i) Access specifier – public, protected or private.
(ii) Method declared without access specifier is by default treated of type package or default.
(iii) Return Type- Specifies the data type of the value returned from the method
(iv) Method name – Preferably related to the program
(v) Parameter list – Variables which receive the value passed from the arguments during method call
For example: There are two components of a method –
Header ( also known as method prototype)
Body List of parameters is called signature
The statement which sends back the value from a method is called program return statement and is used at the
end of the program which is a function terminator.
Different ways of defining a method:
Receiving value and returning outcome to the caller.
Receiving values but not returning outcome to the caller and vice versa.
Neither receiving values nor returning outcome to the caller.
A method is invoked or called by providing the method name followed by the parameters to be sent enclosed in
parenthesis.
For example, a method with prototype as float peri(float l, float b) can be called in the main program as: res =
peri(l,b).
Formal parameter:
Parameter is a variable used with method signature that receives a value during method call.
When the parameter values are received from the caller, then it is called formal parameter.
Actual Parameter: If the values are passed to the method during its call from the caller, then it is actual parameter.
Ways to invoke methods: A method is invoked by two methods–call by value or call by reference depending
upon the ways the arguments are passed to the methods.
(i) Call by Value :
Process of passing a copy of actual arguments to the formal parameters.
Any change made in the formal will not reflect on actual argument.
(i) Call by Reference:
Process of passing the reference of actual arguments to the formal parameters and any change in the
formal parameters will be reflected in the actual parameters also.
A method terminates when either a return statement is encountered or last statement in the method is executed.
A method may contain several return statements but only one of them gets executed.
The method of type void does not return a value and thus it cannot be used in expressions.
Forms of methods:
Pure method, also called accessor.
Impure method, also called mutator.
Pure method or Accessor takes objects as arguments but does not modify the state of the objects.
Impure method or mutator takes objects on an argument and changes the state of the objects.
Method overloading:
Method with the same name but used for different purposes is called as overloaded methods.
It is implemented through polymorphism.
Compiler finds the best match of the method arguments and the parameter list during program compilation
called static binding.
Key Words
Module: A module consists of single block of code.
Method prototype: It is the first line of method definition that tells the program about the type of value returned
and number / type of arguments.
Method signature: It refers to the number and types of arguments. It is a part of method prototype.
Static method: A method declared with the keyword static and can be called by the class name instead of the
object name. It can access only the static data members of the class.
Non-static method: Also called as instance method , they are declared without the static keyword and can access
both the class and instance variables.
8 Oswaal ICSE Revision Notes Chapterwise & Topicwise, COMPUTER APPLICATION, Class-X
CHAPTER-4
CONSTRUCTORS
Revision Notes
Constructor in Java is a special type of method that is used to initialize the object.
Java constructor is invoked at the time of object creation. It initializes the objects. That is why, it is known as
constructor.
The two rules to define a constructor are:-
Constructor name must be same as its class name.
Constructor must have no explicit return type.
Characteristics of Java Constructors
Constructors name must be same as that of its class name.
Constructors are called automatically when an object is created.
Constructors cannot be private.
A constructor can be overloaded.
Constructors cannot return a value.
Constructors do not have a return type (not even void).
They cannot be inherited.
The main use of Constructors is to initialise the object of that class type with a legal initial value.
Types of Java Constructors : There are following types of constructors:-
Default constructor (no-argument constructor)
Parameterized constructor
The parameterized constructors are used to initialize fields of the class with some specific values.
Compiler differentiates constructors on the basis of number of parameters, types of parameters and order of
parameters.
A constructor is a special type of method of a class which is used to initialize a newly created instance of the class.
Constructor Overloading: Constructor overloading is the way of having more than one constructor with different
parameters list, in such a way that each constructor performs a different task.
Key Words
Default Constructor: It is the no-argument constructor that is automatically created by compiler in the absence
of explicit constructor. It will initialize all the class members to the default value as per their Data Type.
Explicit Constructor: It is the constructor that is created by the programmer.
Parameterized Constructor: This constructor is required to initialize objects with user specified values.
Glossary
new: Java Unary Operator
Separators: Comma and Terminators
Signatures: Function definition parameters
CHAPTER-5
LIBRARY CLASSES
Revision Words
Wrapper Classes: Classes that are used for converting primitive data types into objects (also called wrapper
objects) are called wrapper classes. For example, char into Character, double into Double, int into Integer etc.
The primitive data types
are defined in the language itself.
Oswaal ICSE Revision Notes Chapterwise & Topicwise, COMPUTER APPLICATION, Class-X 9
are not objects
do not belong to any class.
In Java, the data structures accept only objects to store. So, to store datatypes as objects in data structures the
wrapper classes are used.
For example,
int x = 15;
Integer objx = new Integer(x);
Wrapper classes also include methods to convert the object into the datatype again.
For example,
int y = objx.intValue();
There are 8 primitive datatypes defined in Java, they are byte, short, int, long, float, double, char, boolean.
Primitive datatypes and their wrapper class
Primitive Datatype Wrapper class
char Character
byte Byte
short Short
long Long
integer Integer
float Float
double Double
boolean Boolean
Autoboxing: It is the process of automatically converting a primitive type to its corresponding wrapper class
object. For example – conversion of int to Integer, double to Double etc.
Unboxing: It is just the reverse process of autoboxing that automatically converts an object of a wrapper class
to its corresponding primitive type is known as unboxing. For example – conversion of Long to long, Double to
double etc.
Java allows us to create new datatype using combination of the primitive datatypes, such datatypes are called
composite or user-defined datatypes.
Just as variables can be declared of any primitive datatype, similarly we can declare variables of the composite
datatypes.
Each of Java's eight primitive datatypes has a class dedicated to it. These are known as wrapper classes.
The most common methods of the wrapper classes are summarized in below table. Similar methods for the
other wrapper classes are found in the Java API documentation.
Method Purpose
int parseInt(String s) returns a integer value equivalent to string s
long parseLong(String s) returns a long value equivalent to string s
float parseFloat(String s) returns a float value equivalent to string s
double parseDouble(String s) returns a double value equivalent to string s
boolean isDigit(Char ch) returns a boolean value, that is, true if the given character is a digit and
false if the given character is not a digit.
boolean isLetter(Char ch) returns a boolean value, that is, true if the given character is a letter
and false if the given character is not a letter.
boolean isLetterorDigit(Char ch) returns a boolean value, that is, true if the given character is either a
digit or a letter and false if the given character is neither a digit nor a
letter.
boolean isLowerCase(Char ch) returns a boolean value, that is, true if the given character is in lower
case and false if the given character is not in lowercase
boolean isUpperCase(Char ch) returns a boolean value, that is, true if the given character is in upper
case and false if the given character is not in upper case.
10 Oswaal ICSE Revision Notes Chapterwise & Topicwise, COMPUTER APPLICATION, Class-X
boolean isWhitespace(Char ch) returns a boolean value, that is, true if the given character is a blank
and false if the given character is not a blank.
char toLowerCase(Char ch) Converts the specified character to lowercase.
char toUpperCase(Char ch) Converts the specified character to uppercase.
Key Words
Wrapper class: Classes that are used for converting primitive datatypes into objects (also called wrapper objects)
are called wrapper classes. For example, char into Character, double into Double, int into Integer
Boxing: It is the process of automatically converting a primitive type to its corresponding wrapper class object.
For example – conversion of int to Integer, double to Double etc.
Unboxing: It is just the reverse process of autoboxing that automatically converts an object of a wrapper class to
its corresponding primitive type is known as unboxing. For example – conversion of Long to long,
CHAPTER-6
ENCAPSULATION
Revision Notes
Encapsulation in Java is a mechanism of wrapping the data (variables) and code acting on the data (methods)
together as a single unit. In encapsulation, the variables of a class will be hidden from other classes, and can be
accessed only through the methods of their current class. Therefore, it also implements data hiding.
To achieve encapsulation in Java:
Declare the variables of a class as private.
Provide public setter and getter methods to modify and view the value of variable.
Benefits of Encapsulation:
The fields of a class can be made read-only or write-only.
A class can have total control over what is stored in its fields.
The users of a class do not know how the class stores its data. A class can change the data type of a field and
users of the class do not need to change any of their code.
Encapsulation is ineffective in absence of access specifiers.
Access specifiers allow to decide how parts of the classes can be accessed by other classes in other parts of the
program. There are four types of access specifiers:
Default (Friendly)
Private
Protected
Public
Scope is defined as the program part in which a particular piece of code or a variable can be accessed.
Visibility refers to whether you can use a variable from a given place in a program. It is the accessibility of the
variable declared.
Visibility rules
Access Specifier Accessible by Accessible by Accessible by sub- Accessible by sub-
classes in the same classes in other classes in the same classes in other
package packages package packages
Default (Package)
Private
Protected
Public
Java offers following levels of scope:
Data declared within a method or block is called local data or local variable.
Oswaal ICSE Revision Notes Chapterwise & Topicwise, COMPUTER APPLICATION, Class-X 11
Data declared at the class level can be used by all methods in that class.
Data declared within a method can be used only in that method.
Variables declared inside the blocks are not visible outside of that block.
Variables declared outside the blocks are visible inside the blocks.
Instance variables are declared in class outside any method or block. These are declared without the keyword
static. These variables can be accessed only by creating objects.
Static variables are declared using the keyword static within a class outside any method or block. These variables
need not be accessed by creating an object of the class but can be accessed with the class_name.variable_name.
An argument variable is used in Java methods where the number of arguments accepted by a method is not
known. This can accept variable number of values and is called varargs.
Key Words
Encapsulation refers to the bundling of related fields and methods together.
This can be used to achieve data hiding. Encapsulation in itself is not data hiding.
CHAPTER-7
ARRAYS
Revision Notes
Java provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same
type.
An array is used to store a collection of data, but it is often more useful to think of an array as a collection of
variables of the same type.
Elements of array will be referred as arrayName [n], where n is the number of element in the array.
Instead of declaring individual variables, such as number0, number1, ..., and number99, you declare one array
variable such as numbers and use numbers[0], numbers[1], and ..., numbers[99] to represent individual variables.
There are two types of array:
Single Dimensional Array: This type of array contains list of variables of same type that are accessed by a
common name. This type of array can have only one full row or one full column.
Multi-Dimensional Array: These are array of arrays. This type of array can have multiple rows and multiple
columns.
Array Declaration: Syntax for array declaration
datatype[] array_name;
where, datatype can be a primitive datatype like int, char, double, byte, etc. or an object. array_name is an
identifier.
To allocate memory for array elements,
array_name= new datatype[size];
where, array_name can hold <size> elements of defined datatype.
To declare and allocate memory to an array in one statement, the syntax is:
datatype[] array_name = new datatype[size];
For example, double[] marks= new double[4];
An array can be initialized during declaration as double[] marks = {90, 75, 86.50, 58.25};
To access each element of an array, for loop is used.
To find the length of an array, length method is used. For example, marks.length.
Basic Operations on Arrays:
Searching: It is the process to determine whether the given element is present in the array or not. These are
of two types–
12 Oswaal ICSE Revision Notes Chapterwise & Topicwise, COMPUTER APPLICATION, Class-X
Linear Search
Binary Search
Sorting: It is the process of arranging data in ascending or descending order. There are two ways to sort the
data–
Bubble Sort
Array as composite type: Arrays contain other values and do not have a standard size. So, they require more
memory than primitive types. Java handles arrays by reference.
Key Words
Array Element: An individual element in the array.
CHAPTER-8
STRING HANDLING
Revision Notes
A string is a term that refers to set of characters. Java provides a class String in java.lang package whose objects
can be treated as variables of type String.
Method Description
String trim() Removes beginning and ending spaces of this string.
String toLowerCase() Returns a string in lowercase.
String toUpperCase() Returns a string in uppercase.
int length() Returns string length.
char charAt(int n) Returns char value for the particular index n.
int indexOf(int char) Returns the specified char value index.
String concat(String str) Concatenates the specified strings.
boolean equals(String str) Checks the equality of a string with the another given string
considering the case.
boolean equalsIgnoreCase(String str) Checks the equality of a string with the another given string
irrespective of the case.
compareTo(String string) Compares two strings based on the Unicode value of each
character in the strings and returns the difference.
int compareToIgnoreCase(String string) Same as compareTo method however it ignores the case during
comparison.
String replace(char oldChar, char Returns the new updated string after changing all the occurrences
newChar) of oldChar with the newChar.
String substring(int beginIndex) Returns the substring of the string. The substring starts with the
character at the specified index.
String substring(int beginIndex, int Returns the substring. The substring starts with character at
endIndex) beginIndex and ends with the character at endIndex-1.
boolean startsWith(String str) Tests whether the string begins with specified str, if yes then it
returns true else false.
boolean endsWith(String suffix) Checks whether the string ends with the specified suffix.