Computer NOTES ICSE 10 2024
Computer NOTES ICSE 10 2024
Computer NOTES ICSE 10 2024
10TH PROGRAMMING
IN 1 VIDEO
Follow me on
Instagram to Get
Updates !
@pranaymishrack
MIC Kholo
Doubt Pucho SERIES | ICSE 10 2024
CIE CIE
Class
Computer's memory
CLARIFY KNOWLEDGE
Class Formation Basic !
Now, inside a class, we need memory allocations for variables to
store data.
Syntax to create a variable:
data_type variable_name=constant/value
For eg:
String var="cons";
var cons
Variable
[String]
Class
CLARIFY KNOWLEDGE
DATA TYPES
D The means to recognize or identify an entity/entities and their
operations are known as data types.
CLARIFY KNOWLEDGE
String Data: We use String data type to store characters i.e. data
enclosed in double inverted commas(" ").
Boolean Data: We use boolean data type to store boolean data i.e.
true and false.
CLARIFY KNOWLEDGE
HOW TO PRINT?
You can print via 2 ways:
System.out.print() : This statement prints the sentence and
keeps the controller in the same line.
System.out.println() : This statement prints the sentence
and brings the controller in the next line.
CLARIFY KNOWLEDGE
Let's store a value in a variable and print it.
int a=7;
String str="Prana";
char ch='y';
double b=1.0;
System.out.print(str+ch+b+a);
-> Pranay1.07
CLARIFY KNOWLEDGE
ESCAPE SEQUENCE CHARACTERS
D The character constant which begins with backslash(\) followed by
one letter that reflects the corresponding output during execution of
code or program is knowns as escape sequence character or non-
graphic character.
For eg: '\a\ , '\n' , '\t' , etc.
\n - New Line
\t - One tab space
\' - Prints single inverted commas(') in output
\" - Prints double inverted commas(") in output
\\ - Prints backslash (\) in output
CLARIFY KNOWLEDGE
IMPLICIT TYPE CONVERSION
Implicit type converion works on this hierachy:
byte
char
short
int
long
float
double
It's just like the reactivity series of chemistry, here the lower data types
are more powerful, they will change the above ones into their data
type.
char + int = int
int + long =long
int + double = double CLARIFY KNOWLEDGE
EXLICIT TYPE CONVERSION
It is forced coversion of data types and is also known as Type
Casting.
For eg:
int a,float b,char c;
d= (char)(a+b*c);
char ch='A';
System.out.print((int)ch);
-> 65
CLARIFY KNOWLEDGE
MIC Kholo
Doubt Pucho SERIES | ICSE 10 2024
CLARIFY KNOWLEDGE
if-else() statement
Syntax:-
if(condition or relational statements)
{
if-code;
}
else(conditional or relational statements)
{
else-code;
}
CLARIFY KNOWLEDGE
NESTED if() statement
Syntax:-
if(condition-1)
True
{ Condition-1 Statement-1
Statement-1
if(condition-2) False
{
False Condition-2
Statement-2; Exit
}
True
}
Statement-2
CLARIFY KNOWLEDGE
NESTED if-else() statement
Syntax:-
if(condition-1)
{
if(condition-2)
{
Statement-2;
}
else()
{
Statement-3;
}
}
else()
{
Statement-3;
} CLARIFY KNOWLEDGE
Flowchart of nested if-else() statement
CLARIFY KNOWLEDGE
Input System
Input Using Parameters
MIC Kholo
Doubt Pucho SERIES | ICSE 10 2024
CLARIFY KNOWLEDGE
INCREMENT(++) AND DECREMENT(--) OPERATORS
The increment operator increases the value by 1 and the decrement
operator decreases the value by 1.
PREFIX NOTATION
The presence of an increment or decrement operator before the
operand or variable is known as prefix notation. For eg: ++A or --A
It first changes the value then uses it. (change-then-use rule)
int A = 3;
int B = 10;
System.out.println(++A);
System.out.println(--B);
Output:-
4
9 CLARIFY KNOWLEDGE
Now lets make a calculator using Scanner!
Step 1:
CREATE A CLASS
Step 2:
CREATE A SCANNER OBJECT
CLARIFY KNOWLEDGE
Step 3:
CREATE A SCANNER OBJECT
Step 4:
ASK FOR USER'S CHOICE
CLARIFY KNOWLEDGE
Step 5:
ASK FOR NUMBERS
Step 6:
CREATE CONDITIONS FOR PROPER WORKING
CLARIFY KNOWLEDGE
Step 7:
JUST PRINT THE RESULT NOW
CLARIFY KNOWLEDGE
MIC Kholo
Doubt Pucho SERIES | ICSE 10 2024
CLARIFY KNOWLEDGE
a positive number -> 9.0
CLARIFY KNOWLEDGE
floor() Returns the lower number Math.floor(argument) Math.floor(1.8) -> 1.0
CLARIFY KNOWLEDGE
the number Math.cbrt(-8) -> -2.0
Q (1 / 3)a³ + (1 / 4)b³
CLARIFY KNOWLEDGE
Q S = ut + 1/2at²
Q d = √ l² + b²
CLARIFY KNOWLEDGE
Q Give the output of the following equations.
if x =-9.99 , calculate Math.abs(x);
if x = 9.0 , calculate Math.sqrt(x);
CLARIFY KNOWLEDGE
Q Give the output of the following functions.
Math.floor(=126.349)
Math.max(45.6 , 17.3)
Math.min(-0.0 , 0.0)
Math.pow(4 , 3)
Math.sqrt(625)
Math.ceil (-12.56)
CLARIFY KNOWLEDGE
MIC Kholo
Doubt Pucho SERIES | ICSE 10 2024
CLARIFY KNOWLEDGE
KEYWORDS OF SWITCH-CASE
switch: It is used to transfer the program control to the matching case
depending on the value of the variable or expression.
case: It contains one or more executable statements that end with a
break statement.
break: It is a jump statement that terminates the execution of the
current case and comes out of the body of switch.
default: It is the last statement of the switch body and executes if the
matching case is not found.
CLARIFY KNOWLEDGE
SYNTAX
switch(value or expression)
{
case constant-1:
statement-block-1;
break;
case constant-2:
statement-block-2;
break;
case constant-N:
statement-block-N;
break;
default:
statement-block-default;
}
CLARIFY KNOWLEDGE
Q Write a menu-driven to check whether a number is
(i) even or odd
(ii) multiple of 17 or not
(iii) two-digit number or not.
CLARIFY KNOWLEDGE
Find the output:
Q
switch(op)
{
case 1: System.out.println("Ck");
case 2: System.out.println("op!");
break;
case 3: System.out.println("Hustle Hard!");
break;
default: System.out.println("Code Is Easy!");
}
op=1
CLARIFY KNOWLEDGE
MIC Kholo
Doubt Pucho SERIES | ICSE 10 2024
SYNTAX :
Keyword for ( Initial-Value ; Test Condition ; Update-statement )
{
Statement-blocks;
}
CLARIFY KNOWLEDGE
WHILE ( ) LOOP
D The loop that executes one or more statements till the condition is TRUE
and terminates the iteration when the condition is FALSE .
SYNTAX :
while ( expression or condition or relational expression)
{
Statements-block
}
CLARIFY KNOWLEDGE
DO-WHILE ( ) LOOP
D The loop that executes one or more statements till the condition is TRUE
and terminates the iteration when the condition is FALSE, is known as do-
while( ) loop.
SYNTAX :
Keyword do
{ SEMICOLON COMPULSORY
Statement-block
}
Keyword while( condition or relational expression);
CLARIFY KNOWLEDGE
MIC Kholo
Doubt Pucho SERIES | ICSE 10 2024
CLARIFY KNOWLEDGE
Q Java Program to Display Even Numbers From 1 to 100
using "for loop".
CLARIFY KNOWLEDGE
Q Write a program in Java to display the following pattern:
1
22
333
4444
55555
CLARIFY KNOWLEDGE
Q Write a program in Java to display the following pattern:
54321
4321
321
21
1
CLARIFY KNOWLEDGE
Q Write a program in Java to display the following pattern:
3
44
555
6666
77777
CLARIFY KNOWLEDGE
Q Write a program in Java to display the following pattern:
5
44
333
2222
11111
CLARIFY KNOWLEDGE
Q S =1 * 2 + 2 * 3 + 3 * 4 + 4 * 5 + 5 * 6 + 6 * 7 + 7 * 8 + 8 * 9 + 9 * 10
CLARIFY KNOWLEDGE
Q S = 1 + 1/ 2 + 1/3 + 1/4 + 1/5 + 1/6 + 1/7 + 1/8 + 1/9 +1/10
CLARIFY KNOWLEDGE
Q S = a/2 + a/3 + a/4 + a/5 + a/6 + a/7 +a/8 + a/9 + a/10
CLARIFY KNOWLEDGE
Q S = 1+2/1*2 + 1+2+3/1*2*3 + 1+2+3+4/1*2*3*4 + 1+2+3+4+5/1*2*3*4*5
up to "n"terms
CLARIFY KNOWLEDGE
Q Accept a number and check whether it is perfect or not.
A number is said to be perfect if sum of all its factors excluding the
numbers itself is equal to the original number
CLARIFY KNOWLEDGE
Q Accept a number and check whether the number is a buzz
number or not.
A number is said to be a buzz number if it either ends with 7 or is
divisible by 7.
CLARIFY KNOWLEDGE
Q Write a program to print digits and count of digits in the number.
CLARIFY KNOWLEDGE
Q Accept a number and check whether the number is palindrome or
not.
If a number and its reverse form is same then the number is a
Palindrome number.
CLARIFY KNOWLEDGE
Q Accept a number and check whether the number is neon or not.
If sum of digits of square of a number is equal to the original
number then the number is said to be Neon.
For eg :- 9
9*9 = 81 and 8+1=9
CLARIFY KNOWLEDGE
MIC Kholo
Doubt Pucho SERIES | ICSE 10 2024
Class 10 (COMPUTER)
Thoery
INTRODUCTION
So far, you have studied the methods and the way they work in Java. Now
you will be learning a different type of method. It is known as a
constructor and its most distinguishing feature is that it is named after
the class it is in. Let us find out more about the constructor.
CLARIFY KNOWLEDGE
CONSTRUCTORS
A constructor is a special member method of a class without a return
type. It is used for initialising and constructing the data members of an
object when it is created. It is automatically called (invoked) when the
object is created using new operator. It cannot be invoked by the user like
normal methods.
CLARIFY KNOWLEDGE
CHARACTERISTICS
A constructor will have the same name as that of the class.
A constructor does not have a return type not even void.
A constructor cannot be static or final.
A constructor must be declared public (if it has to be accessed outside
the class).
It is automatically called (invoked) when an object is created.
CLARIFY KNOWLEDGE
NEEED OF A CONSTRUCTOR
A constructor is used for initialising and constructing the data members of
an object with legal values when it is created. Data members are mostly
declared as private members, to implement data hiding and abstraction.
Due to this, data members cannot be initialised outside the class with
values. So, constructors are used for initialising the objects implicitly as
they are created.
CLARIFY KNOWLEDGE
DECLARING AND DEFINING
Being a method, it also gives the programmer the ability to define,
declare and modify. Since, a constructor has no return type (not even
void), it also provides the programmer with the liberty to define a
constructor with or without a parameter.
A simple constructor is created using the new operator followed by the
name of the class.
Syntax:
<access specifier> class_name (parameter list/void)
{
Data_member1 = value1 ;
Data_member2 = value2;
}
CLARIFY KNOWLEDGE
EXAMPLE:
class Book
{ int bookno;
String name;
float price;
public Book() //constructor is created, having same name Book as
{ bookno = 0; that of its class name Book, with public access specifier
name = "ABC"; and no return type.
price=0.0
} }
CLARIFY KNOWLEDGE
TYPES OF CONSTRUCTORS
The main function of a constructor is to initialise the data members of an
object while it is created. Constructors can be broadly categorised into
two categories based on the parameters it takes:
CLARIFY KNOWLEDGE
DEFAULT CONSTRUCTOR/NON PARAMETERISED CONSTRUCTOR
A constructor that takes no parameters is called a default constructor. It
will have the name of the class and have no return type. If you do not write
a constructor in your program, the compiler will supply a default
constructor and initialise values with the default values of the primitive
data types i.e. integer variables to zero, floating point variables to 0.0 and
String to null.
Syntax:
class_name()
{
Data_member1 = value1;
Data_member2 = value2;
}
CLARIFY KNOWLEDGE
PARAMETERISED CONSTRUCTOR
Constructor that takes one or more parameters or arguments is called as
a parameterised constructor. Such a constructor will accept values and
initialise the data members with the corresponding values. There is no
limitation to number of parameters.
Syntax:
class_name (type1 val 1, type2 val 2...)// parameter list
{
Data_member1 = val 1;
Data_member2 = val 2;
}
CLARIFY KNOWLEDGE
'THIS' KEYWORD
'this' keyword is used within a constructor to refer to the current object. It
is actually a reference to the object that invokes the constructor. In fact,
even if you do not use the this keyword, the compiler normally implicitly
converts it by prefixing this to the data members.
CLARIFY KNOWLEDGE
constructor member methods
CLARIFY KNOWLEDGE
CONSTRUCTORS WITHIN CONSTRUCTORS USING 'THIS'
CLARIFY KNOWLEDGE
String !
Integer - Number
Integer - Word Parameter
String
Taking the Input of String
Pre described
String A = "apple";
From Scanner
String B = sc.nextLine();
Indexing and Length of the String
String A = "Pranay Mishra"
Note :- Indexing always starts from 0 and ends with the
one smaller than the length of the string.
Length function
int length = A.length();
length = 13;
INDEXING
Pranay Mishra
Character at the Position.
String A = "Pranay Mishra"
Note :- It picks the Character as per the Indexing done.
char ch = A.charAt(8);
char ch = ?
FUNCTIONS OF THE STRING
equals()
equalsIgnoreCase()
FUNCTIONS OF THE STRING
compareTo()
compareToIgnoreCase()
FUNCTIONS OF THE STRING
indexOf()
lastIndexOf()
FUNCTIONS OF THE STRING
substring() -
if the last index is given , it is
excluded from the substring.
FUNCTIONS OF THE STRING
concat() -
Alternative
temp = "apple";
ch = 'a';
temp = temp + ch;
temp = ch + temp;
FUNCTIONS OF THE STRING
replace();
FUNCTIONS OF THE STRING
endsWith();
startsWith();
FUNCTIONS OF THE STRING
toLowerCase();
toUpperCase();
FUNCTIONS OF THE STRING
toLowerCase();
toUpperCase();
FUNCTIONS OF THE STRING
trim()
valueOf()
WAP TO PRINT THE NUMBER OF CHARACTER IN THE WORD
WAP TO PRINT THE FIRST WORD OF THE NAME AND SURNAME.
PRANAY MISHRA - P.M.
WAP TO CHECK WHETHER A WORD IS PALINDROME OR NOT.
computer - cpmpvtfr
Do this.
ARRAY !
collection of a similar data and working as an single entity.
For example: int A[10] represents the array of the integer data type
that can hold 10 values. This memory location of A[10] will be
A[0], A[1], A[2], . . A[9] .
CLARIFY KNOWLEDGE
MIC Kholo
Doubt Pucho SERIES | ICSE 10 2024
CLARIFY KNOWLEDGE
Input of an Array.
int m[] = new int[10];
int l = m.length;
CLARIFY KNOWLEDGE
WAP to collect 10 Integers and print the Sum of them.
CLARIFY KNOWLEDGE
Linear Search !
Write a program to search for an integer value input by the user in
the list given below using linear search technique. If found display
"Search Successful" and print the index of the element in the array,
otherwise display "Search Unsuccessful".
{75, 86, 90, 45, 31, 50, 36, 60, 12, 47}
CLARIFY KNOWLEDGE
import java.util.Scanner;
int arr[] = {75, 86, 90, 45, 31, 50, 36, 60, 12, 47};
int l = arr.length;
int i = 0;
CLARIFY KNOWLEDGE
Binary Search !
Write a program to perform binary search on a list of integers given
below, to search for an element input by the user. If it is found
display the element along with its position, otherwise display the
message "Search element not found".
5, 7, 9, 11, 15, 20, 30, 45, 89, 97
CLARIFY KNOWLEDGE
import java.util.Scanner;
CLARIFY KNOWLEDGE
Output
CLARIFY KNOWLEDGE
Bubble Sort !
Write a program to input 15 integer elements in an array and sort
them in ascending order using the bubble sort technique.
CLARIFY KNOWLEDGE
import java.util.Scanner;
//Bubble Sort
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (arr[j] > arr[j + 1]) {
int t = arr[j];
arr[j] = arr[j+1];
arr[j+1] = t;
}
}
}
System.out.println("Sorted Array:");
for (int i = 0; i < n; i++) {
System.out.print(arr[i] + " ");
}
}
} CLARIFY KNOWLEDGE
Output
CLARIFY KNOWLEDGE
Selection Sort !
Write a program to input and sort the weight of ten people. Sort and
display them in descending order using the selection sort technique.
CLARIFY KNOWLEDGE
import java.util.Scanner;
double t = weightArr[i];
weightArr[i] = weightArr[idx];
weightArr[idx] = t;
}
}
} CLARIFY KNOWLEDGE
output
CLARIFY KNOWLEDGE
CLARIFY KNOWLEDGE PRESENTS
2D Array
CLARIFY KNOWLEDGE
subscript
of array
[ ]
00
10
20
0 1 2
01
3 4 5
11
6 7 8
21
02
12
22
CLARIFY KNOWLEDGE
Row column
[ ] [ ]
00
10
20
0 1 2
01
3 4 5
11
6 7 8
21
02
12
22
00
10
20
0 1 2
01
3 4 5
11
6 7 8
21
02
12
22
CLARIFY KNOWLEDGE
Output:
CLARIFY KNOWLEDGE
[ ] [ ]
00
10
20
0 1 2
01
3 4 5
11
6 7 8
21
when i==j
02
12
22
00
10
20
0 1 2
01
3 4 5
11
6 7 8
21
02
12
22
when i+j==2
left diagonal elements are found right diagonal elements are found
CLARIFY KNOWLEDGE
LOGIC:
CLARIFY KNOWLEDGE
Output:
CLARIFY KNOWLEDGE
Output:
MIC Kholo
Doubt Pucho SERIES | ICSE 10 2024
Member methods:
void accept(): Accept the name and the price of the item
using the methods of Scanner class.
void display(): To display the name of the item and the net
amount to be paid.
Write the main method to create an object and call the above
methods.
import java.util.Scanner;
public class Eshop
{
private String name;
private double price;
private double disc;
private double amount;
void display(int n): To print the square root of each digit of the given number.
Example:
n = 4329
Output – 3.0
1.414213562
1.732050808
2.0
import java.util.Scanner;
System.out.println("Pattern: ");
obj.display();
}
}