0% found this document useful (0 votes)
33 views11 pages

Class10notes 2024

Uploaded by

tapaskumarmahato
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views11 pages

Class10notes 2024

Uploaded by

tapaskumarmahato
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

ST.

PETER’S SCHOOL, PURULIA, WEST BENGAL


COMPUTER APPLICATIONS
NOTES FOR CLASS X
1.Name any two elements of OOP.
a.The elements of OOP are – Object, Classes, encapsulation, inheritance.

2.Define Encapsulation with an example.


a.The wrapping up of data and functions into a single unit is known as encapsulation. Eg. CLASS.

3.Define a class.
a.A class is a user defined data type or blue print that defines the variables and the methods common to
all of a certain kind.

4.Define an object.
a.Object is a variable of type class. It is an instance of a class.

5.Define Data abstraction.


a. Data abstraction is to represent essential features of a system without getting involved with
the complexity of the entire system.

6.Define Inheritance with an example.


The property by which the property of one class can be acquired by another class is termed as
inheritance. Eg : Math.Pow().

7.Define derived class and base class.


a.The class whose property is acquired is called the base class. The class in which the property of the base
class is acquired is called the derived class.
Eg. Math.pow (a, b) – Math is the base class and pow(a,b) is the function acquired in the class defined.

8.Define Polymorphism.
a. Polymorphism is the capacity to allow objects having different internal structures to share the
same exernal interface. Polymorphism can be classified as Operator overloading, Function overloading.

9.What is Function overloading ? Give an example.


a. Many functions of a class having the same name but with different set of arguments is termed as function
overloading. Eg : void area (double s) , void area ( double l, double b), void area (double a, double b,
double c), void area( ).

10. What is operator overloading? Give an example.


a. One operator being used in different ways is termed as operator overloading. Eg. “ + “ operator
when placed in between two numbers – adds the two numbers – ( 2 + 3 = 5), “ + “ when placed in
between two strings concatenates the strings as one – (“COMPUTER”+”APPLICATIONS” =
“COMPUTERAPPLICATIONS”
), “ + “ symbol is used to represent the sign of the number, also used as increment operator.

11.Static variable – variables declared as static is common to all the objects created from the same
class. They can be accessed without creating an object. Any changes made to the value of the static
variable are visible in all the object of the given class.

12. Define local variable.


a. These variables are declared in the method/ function. These variables can be accessed only by
the function in which they are declared, but other methods cannot access these variables.

13. Define instance variable.


a. Variable declared within a particular instance only. They are active as long as the instance is active. Once
the instance is completed the variable cannot be accessed by the method also.

14. Mention the two types of Java programs.


a.Stand alone programs, applets, servelets.

15. Define bytecode, JVM, JDK.


a. Byte code : is the set of pseudo machine language instructions that are understood by the
JVM independent of the underlying hardware.
JVM – Java Virtual Machine is an abstract machine that executes a java program.
JDK – Java Development Kit.
16. Define Wrapper Classes. Give an example.
a. A wrapper class wraps a value of primitive type of object. Eg. Math, Character classes. The functions
of these classes can be invoked with respect to the class name itself instead of an object. Eg : Math.sqrt ( 16 ) ,
Character.isUpperCase ( Char ).

17. Define Tokens.


a. The smallest individual unit of a program is known as token. The different tokens of java are – Keywords,
punctuators, identifiers, operators, literals.

18. Define type casting. What are the two types of typecasting? Explain with an example.
a. The process of converting one predefined data type to another is called as type casting. The two types of
type casting are – implicit typecasting and – explicit type casting .
Implicit type casting : Converting a variable of data type to another data type automatically when assigned is
termed as implicit type casting. Eg : int x = ‘A’
Explicit type casting : Converting a variable of a data type to another data type by specifying the required
data type is termed as explicit type casting. Eg : int x = (int ) ‘a’.

19. What do you mean by comment statement ? what are the types of comment statements in java?
a. A comment statement is a non executable statement. The two type os comment statements in java are
single line comment ( // ) and multiline comment (/* …….* / )

20. Define Identifiers, literals, keywords, data type.


Symbolic names used for various data items in a programs such as variables, classes, methods are known
as identifiers.
A data item which does not change its value during the execution oif a program is called as a literal or
constant.
Keywords are reserved words that convey special meaning to the compiler.
A datatype is defined as the set of possible values a variable can hold.

21. Mention the two types of data types, give example for each.
a. The two types of data types are Primitive data type and Non primitive datatypes, Eg. int, char are primitive
data types, class, array, string are derived or non primitive data types.

22. Mention the size in bits and bytes of all primitive data types.

24. Mention any two escape sequences.

Escape sequences are characters used for special task like a new line , tab spacing , to insert quotations in a
text etc., escape sequence is of data type char and occupies two bytes.

Example : /n – new line , /t – tab spacing /” – to insert “ in the text


/’ – to insert a ‘ in the text // - to insert / in the text

25. Define separators. Give examples.


a.Few characters used as punctuators are termed as separators. Eg ;, [ ] , ( ), { }

26. What are different access specifiers?


a.Public , private, protected, final

27. What are the different types of operators in java?


a.Arithmetic, relational, logical, ternary, increment, decrement & shortcut operators.

29. Give one difference and one similarity between logical and relational operators.
a. Both the operators result in Boolean data type. Relational operator is used to check one condition,
whereas logical operator is used to check for more than one condition.

30. What do you mean by java expression ?


a.Operands along with the operators represent an expression.

31. Differentiate between operator and expression.


a.Operator is a special symbol which performs a specific operation, whereas expression is a combination of
operators and operands.

32. Differentiate between primitive and non primitive data types.


a. Primitive data types are inbuilt data types and can be declared using the library packages, whereas the
non primitive data types are defined by the user as per the requirement using the primitive data types by
using the key word NEW.

Eg : int x [ ] = new int[10] – allocation of memory locations as per the user’s choice.

33. Differentiate between print and println.


a.Print – prints the data in a line one beside the other.
Println – prints the data in a new line

34. Differentiate between Runtime . logical, syntax errors


Syntax Logical Runtime
Errors caused due to not following Errors caused due to not following Errors caused during the
the rules of the language. logic of the program execution of the program
These errors are recognized by These errors are not recognized These errors are not recognized
the compiler by the compiler by the compiler
Program cannot be executed if Program is executed but the Program is executed but
these errors are not cleared output obtained is not correct. terminates abruptly due to these
Eg : x = ½ * 5 * 4 = 0 as ½ = 0 but errors.
not 0.5 Eg : Math.sqrt ( 16 – 25 )
Division by zero, array out of
bounds

35. What are conditional operators ? Give an example.


a. Conditional operators are ? and :. These are used for checking a condition, if the condition is true the
statement after the ? is executed, if the condition is false the statement after : is executed. The output of the
statement is always assigned to a variable but cannot be printed.
Eg : x = a>b ? 4 x 3 : 4 + 3 ;

36. What are the two conditional statements of Java?


a.The two conditional statements of java are if and switch case.

37. What is the other name for the switch case statement ?
a.Multiple branching statement.

38. What do you mean by compound statements?


a.More than one statement enclosed in { } are termed as compound statements.

39. Differentiate between if and switch.


If Switch
Conditional statement Multiple branching statement
All relational and logical operators can be used Checks only for equivalence
All data types can be used Only character and integers can be used

40. Differentiate between EXIT and BREAK.


EXIT BREAK CONTINUE
Function Statement Statement
Stops the execution of the function Stops the execution of the Continues the execution of
construct in which it is placed construct ignoring the
statements given after
Has to be prefixed with System., and Need not be prefixed as it is a Need not be prefixed with any
the argument 0 to be added eg : statement class name as it is a statement
System.exit(0)

41. What is the purpose of default in switch case ?


a.Default in switch case is given to handle the exceptional cases. It is an optional statement.

42. What is the purpose of break in switch case?


a.Break in switch case avoids the fall through of the cases.
43. What is looping? What are the looping / iterative statements of java?
a. Repetitive execution of set of statements is termed as looping. The iterative statements of java are
FOR, WHILE and DO WHILE.

44. Write the syntax of all the three looping statements.


45. What are the elements of a looping statement?
a.Initialization, check/condition, increment or decrement.

46. Differentiate between FOR , WHILE and DO WHILE.


FOR WHILE DO WHILE
Entry control loop Entry control loop Exit control loop
Used when no. of iterations are Used when no. of iterations are Used when no of iterations are not
known not known known
Is not executed even once if the Is not executed even once if the Executed at least once even the
condition is false condition is false condition given is false

47. What is an infinite loop? Give example using all the three looping statements.
a.A loop which never ends is termed as infinite loop.
Eg : FOR – for ( ; ; )
WHILE – while (true)
Do while – do { Statament } while(true);

48. What is a nested loop?


a.A loop with in another loop is termed as nested loop. For every counter of the outer loop, the inner loop is
executed.

49. What are Jump statements?


a.Statements which transfer the control unconditionally within a function are termed as jump statements. Eg
: Break, continue, return.

50. Define Package.


a.A package is a collection of classes that can be shared by the java programs.
The two important packages used are – java.io.*, java.lang.*. These packages can be accessed within a class
by using the import statement. The other packages using in java are – java.util.* for the scanner class.

51. What is an applet?


a.An applet is a java program which is executed in a web page.

55. What do you mean by Static method and static variables?


a. Static method – A method declared as static can be invoked without creating an object.
Static variable – variables declared as static is common to all the objects created from the same class. They
can be accessed without creating an object. Any changes made to the value of the static variable are visible
in all the object of the given class.

56. How do you create an object of a class ? give example.


a. Objects of a class can be created by using the keyword NEW.
Syntax : <class name > <object name> = new < class name >;
Eg : to create two objects Yamaha and bajaj of the class bikes :
bikes Yamaha = new bikes( ); bikes bajaj = new bikes ( );

57. Define an array.

a. Array is the name to given to continuous memory locations to store elements of similar data types where
in each element is accessed by the position of subscript. Thus an array variable is also termed as
subscripted variable.

58. State one advantage and one disadvantage of arrays.


a. Multiple values can be accessed with a single variable name, but memory is misused in arrays.

59. What do you mean by the size of an array? What is the statement to get the size of the array?
a. Size of an array is the number of elements in an array. To obtain the size of the array the statement length
is used.
x.length – results in the size of the array.
60. Define sorting and searching.
a. Sorting : Arranging the elements of an array either in ascending or descending order is termed as sorting.
Searching : Checking for the existence of a given element in the array is termed as searching.

61. Differentiate between bubble sorting and selection sorting.


Bubble Sorting Selection Sorting
Comparison of consecutive elements , the whole Each element of the array is replaced with the
process done element number of times smallest element in the rest of the elements
When elements are sorted in ascending order, the When the elements are sorted in ascending order the
largest element is pushed to end of the array smallest element is shifted to the left of the array

62. Differentiate between Linear search and binary search.


Linear Search Binary search
Checking for the existence of the element in an array Checking the existence of an element considering
sequentially the middle value
Array need not be sorted Array has to be sorted

63. Differentiate between sorting and searching.


Sorting Searching
Arranging the elements in ascending or descending Checking for the existence of the element in the
order array.
The order of the elements are changed Order of the elements is not changes except in
binary search as the elements need to be sorted

64. What is a two dimensional array?


a. A two dimensional array is the name given to continuous memory locations to store elements of
similar data type organized as a table / matrix , where each element is accessed by two subscripts the row
and the column.

65. What is the size of a two dimensional array?


a. The size of an array represents the number of elements in the array, for a two dimensional array the
number of elements is given by the product of rows and columns.

66. How do you initialize a two dimensional array ?


a. <Datatype> < Name> [ ] [ ] = { { list of elements in each row}, {……},{…..} }
Eg : int x[ ] [ ] = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12} };
Note : all the rows should have the same number of elements.

67. Define string.


a. String is a derived class to represent a group of characters enclosed in double quotes.

68. Name the package to use strings.


a. java.lang

69. What is scanner class? Which package it belongs to? What are the different functions of scanner class?
a. Scanner class is used to accept the data through streams. It belongs to the java.util.* package.
The different functions of scanner class are – nextInt ( ) – to accept an integer, nextDouble( ) – to accept
double value , next( ) – to accept a string. All these functions are used with respect to the object of the scanner
class created.
Eg : Scanner ob = new Scanner ( System.in);
int x = ob.nextInt(), double y = ob.nextDouble( ), String s = ob.next( );

70. Name the primitive classes.


a. Math and Character classes are termed as primitive classes. The functions of these classes are to be
prefixed with the class name.

71. What are wrapper classes?


a. Classes which are included in the standard packages java.lang, they are predefined class, functions of
these class can be invoked without creating an object but they are accessed by prefixing the function
with the respective class name. Eg. Math, Character.[ Math.pow(), Character.toUpperCase( )]

72. What is the function of the keyword “new”?


a. The keyword new is used when an object[variable] of derived data type is created, the statement allocates
the memory n the specified format to the specified variable.
Eg : int x[] = new int[10]; Scanner ob = new Scanner(System.in)

FUNCTIONS

1.What is a function? What are the advantages of functions?


a. A function is a set of block of statements with a name, access specifier and return type which can
be called more than once in a program. The advantages of function are reusability, modularity.

2.What is a function signature?


a. The access specifier, return type along with the name of the function and the arguments is called
the function signature. Eg : public boolean prime (int n)

3.What are the two ways of invoking a function?


a.The two ways of invoking a function are – CALL BY VALUE, CALL BY REFERENCE

4.What is call by value?


a.Invoking a function by passing the values as arguments. Eg : if (prime (n))

5.What is call by reference?


a.Invoking a function by passing the reference of the value [ object ] to the function as argument.
Eg: if palen (S[i]) ) *************

6.What is the function of return statement?


a.It transfers control back to the calling function, returns a value to the calling function.

7.What are actual parameters, formal parameters?


a. Actual parameters : The parameter that appears in function call statements are called as actual
parameters. Eg : s + = fact(n).
Formal parameters : The parameter that appears in the definition of a function are called as
formal parameters : Eg : public int fact( int n)

8.What are pure and impure functions?


a. Pure function : The function which do not change the state of the argument is termed as pure
function.
Eg : double area (double x, double y) { return x * y;}
Impure function : The function which changes the state of the argument is termed as impure
function.
Eg : function which calculates the sum of the digits of a number

9.Define constructor.
a. Constructor is a METHOD which has the SAME NAME OF THE CLASS which DO NOT HAVE A
RETURN TYPE , which INITIALISES THE GLOBAL VARIABLES which GETS INVOKED AUTOMATICALLY
EVERY TIME A NEW OBJECT IS CREATED.

10. Define default constructor.


a. Every class defined in java has an inbuilt constructor called the default constructor which
initializes the global variables to their default values.

11. What is a non parameterized constructor?


a.Constructor which initializes the global variables with values.
Eg : public <class name> ( ) { pi = 22.0/7; }

12. What is a parameterized constructor?


a. Constructor which initializes the global variables with values given by the user at the time if object
creation.

13. Differentiate between constructor and function.


Constructor Method / function
Function Function
Same name as of the class Need not be the same name as of the class
No return type is given Return type has to be given
Initializes the global variable Performs a particular task as per the instructions
Invokes automatically every time an object is Has to be invoked from another function.
created
14. What is the function of the keyword “FINAL”?
a.The final keyword converts the variable into a constant whose value cannot be changed at any
stage in the program.

Constructor overloading : A class which a set of constructors to initialize the variables, according to
the way the values are passed.

Eg Program which illustrates constructor overloading


public class overload
{
int x,y;  instance or global variables
overload()
{
x=5; - non parameterized constructor to initialize the global variable to a value
}
overload(int a, int b)
{
x=a;y=b;  parameterized constructor to initialize the global variables
}
void calc()
{
System.out.println(x*6);
}
void perform()
{
int z = 4;
System.out.println(x * y);
}
static void main()
{
overload a = new overload();  creating object without a parameter
overload b = new overload(3,4);  creating object with parameters
a.calc();  the output of this method will be 30 as x = 5
b.perform();  the output of this method will be 12 as the parameters passed are 3 and 4
}
}
Conversions : Functions of wrapper classes are used for conversion of one data type to another

To convert a string to a number

Eg : String s = “4562”; int n; double x;

To convert a string to an integer To convert a string to a double


n = Integer.parseInt (s) x = Double.parseDouble (s)
n = Integer.valueOf (s) x = Double.valueOf (s)

To convert a Number to String

Eg : String s , z; int n=4562; double x = 265.56

To convert interger to a String To convert a double value to String


s = Integer.toString(n)  “4562” z=Double.toString(x)  “265.56”

To Convert a character array to a String

char ch[ ]={‘C’,’O’,’M’,’P’,’U’,’T’,’E’,’R’}; String s = new String(ch);  s= “COMPUTER”

byte b[ ] = {67,65,66,32,65,67,69}; String s = new String (b); s= “CAB ACE”

Autoboxing, Boxing, Unboxing :


Autoboxing : Conversion of a primitive data type variable to an object of the same
primitive class [ wrapper class ]
Eg : int x = 75;
Integer num = x; [ value stored in num = 75 ]
[class] [object] [variable]

Boxing : Creating objects of the wrapper classes using the keyword new.

Eg : int x = 76; double z = 56.87; char ch = ‘w’;

Integer num = new Integer(x); num = 76


Double d = new Double (z); d = 56.87
Character c = new Character (ch); c = ‘w’

Unboxing : Process of Objects created converted back to the variables.

X = num;
Z = d;
ch = c;

Tokens – page no 16, 17, 18 of text book


Size of data types – page no. 20 of text book
Operators – page no. 23,24,25 of text book [ Precedence of Operators –
Important ]
Math Functions – page no. 28,29,30,31 of text book [ Math functions 1 – 14 ]
Static variable and instance variable – page no. 39
Scanner class – page no. 358, 359
Character functions – page no. 334, 335, 336,337
String functions – page no. 337,338,339,340,341,342,343,344,345,346
Math methods

S.no Method Purpose Argument Return type


1 Math.sqrt(n) Squareroot of a given positive number
int / double double
2 Math.pow(a, b) To calculate a raised to b
int / double double

3. Math.cbrt(n) Cuberoot of the given number Int / double Double

4. Math.ceil(n) Rounds off the number to the double double


nearest integer greater than the
number

5 Math.floor Rounds off the number to the nearest double Double


integer smaller than the number

6. Math.random() Generates a random number between No argument Double


0 and 1

7. Math.abs Returns the absolute value of the int / double int / double
number
8. Math.round Rounds off the number to the nearest double Int
integer

9. Math.max Returns the maximum value of the two Two arguments int / double
given numbers [int / double ]

10. Math.min Returns the miniimum value of the two Two arguments int / double
given numbers [int / double ]

Character methods

S.no Method Purpose Argument Return type

1 Character.isUpperCase Checks if the character is an char boolean


uppercase letter or
not

2 Character.isLowerCase Checks if the character is a char boolean


lowercase letter or
not

3 Character.isDigit Checks if the character is a digit or char boolean


not

4 Character.isWhitespace Checks if the char boolean


character is a blank space or not

5 Character.isLetterOrDigit Checks if the character is an char boolean


alphabet or a digit

6 Character.isLetter Checks if the character is an char boolean


alphabet or not

7 Character.toUpperCase Converts the character to char Char


uppercase

8 Character.toLowerCase Converts the character to uppercase char Char

String Methods
S.no Method Purpose Argument Return type
1 length() Returns the number of characters in the - Int
string

Return the character at the given position


2 charAt() Position begins from 0 int char
3 toUpperCase() Converts the - String
lowercase letter to uppercase

4 toLowerCase() Convert the upper case letter to - String


lower case

5 replace(char, char) Replaces all the occurrences of the char / String String
replace(String,String) string / char with the specified char /
string

6 Concat Joins the two string together as one String String


string

7 substring Extracts a part of the string int , int String

8 equals Checks for equality of two strings String boolean

9 equalsIgnoreCase Checks for equality of two strings String boolean

10 compareTo Compares two strings and results in String int


the ascii code difference of the first
non matching characters, if the two
strings have the same set of
characters it results in the
difference of their lengths

11 indexOf Results in the position of the first char / String int


occurrence of the given character /
string

12 lastIndexOf Results in the position of the last char / String int


occurrence of the given character /
string

13 startswith Checks whether the given string String boolean


begins with the specified string or
not

14 endswith Checks whether the given string ends String boolean


with the specified string or not

15 compareToIgnoreCa Compares two strings and results in String int


se the ascii code difference of the first
non-matching characters ignoring the
case

You might also like