Notes for Computer Application I.C.S.E. class X


CLASS X                          SUBJECT COMPUTER APPLICATION 
NOTES BY MUKUL SINHA
Chapter 1  
INTRODUCTION TO CLASSES

VERY SHORT & SHORT ANSWER TYPE QUESTIONS
Q1. Name two OOP's principles.
Ans:- Encapsulation and Abstraction are two OOP's principles.
Q2. What is an Object.
Ans:- An object is an identifiable entity , which contains characteristics and behaviours.
Q3. What is Polymorphism.
Ans:- Polymorphism is an act of using a function for more than one purpose.
Q4. Name two OOP's languages.
Ans:- Java and C++ are object oriented programming languages.
Q5. What is byte code?
Ans:- Byte code is the end product of the compiler(software to convert a source code into byte code). Java Interpreter further converts byte code to machine code.
Q6. What is JVM?
Ans:- JVM stands for Java Virtual Machine also called Java interpreter. It converts byte code into machine code.
Q7. Name two packages used in java.
Ans- java.io and java.lang are two packages in java.
Q8. Name a package, which java language used by default.
Ans- java.lang is a package, which java language used by default
Q9. Name a keyword applied to include a package.
Ans:-"import" is a keyword applied to include a package.                  
Q10. What is a keyword? Give example.
Ans: A keyword is a reserved words which carries special meaning for the compiler. A keword cannot be used as a variable.
Q11. Name two types of comments used in java.
Ans: Single line comment(//) and multiline comment(/*.........*/)
Q12. Name a windows based environment in Java.
Ans: Blue J is a windows based environment in Java.
Q13. Who developed Java?
Ans:- James Gosling developed Java.
Q14.  What is the hypothetical name of java ?
Ans:- OAK is the hypothetical name of java.
Q15. What is a Source Code?
Ans: A Source code is a program in high level language (say Java). entered through console is known as a source code.
Q16. What do you mean by Applet?
Ans:- Java Applet are Java programs, which can be downloaded from Internet.
Q17. What is Object? Give examples of some real world objects.
Ans:- An object is instance of a class. Basically an object is a run time entity which work for implementation of a class.
Q18. What is class How it is related to object?
Ans:- A class is a collection of objects, objects are created when class is formed. Actually object implements class. It(object) works as it defined in class.
Q19. Define Data Abstraction. Explain with example.                                                                                                                                                                    (ICSE 2010,2016)           
Ans:-An abstraction is an act of representing essential features without including background details. For example an abstraction is like a switch board ,you only press certain switches according to you requirement.   
Q20. Define Encapsulation.
Ans:-Encapsulation is an act of combining both data and the functions that operate on the data under a single unit. encapsulation, in a way, implements abstraction. In other words wrapping up of data and its member functions into a single unit.
Q21. What is message Passing amongst object?
Ans:-A way of sending/ receiving information to/from another object.
Q22. What is method? What do they represent?
Ans:-A member function/methods representing some behaviour of an object.
Q23. What is Information Hiding(Data Hiding)?
Ans:- An abstraction is an act of representing essential features without including background details. For example an abstraction is like a switch board ,you only press certain switches according to you requirement.   
This phenomenon is called information hiding.
Q24.Name two elements which are essential to define a class .                                                                                                                                            (ICSE 2001) .
Ans:-Two elements which are essential to define a class  are  (1) Data Members  (2) Member Methods
                                                                                                                       
Q25.Predict the output when
int a=5, b=18,c=6;
(i) a-=(++a + --b)*c++;                   Ans (24)
(ii) c=c*(a-- + b++)+2*++a;          Ans(150)
Solution:-
(i)    Here a=5 b=18 and c=6
first calculate (++a + --b)*c++
(++a      +        --b    )                                 +            c++
(6          +        17     )             +            6(as c incremented after calculation post incremented so taken as c=6 not c=7)
=23+6=29
second calculate  a-=(calculated part)    which is equal to a=a-(calculated part)   
a=a-29
a=5-29=-24
(ii) Here again a=5 b=18 and c=6
first calculate c*(a-- + b++)+2*++a;
c    *      (       a--       +        b++       )      +      2      *      ++a;
6    x      (      5          +        18          )      +      2      *      6;
6 x (23)+12=138+12=150
Q26. What is JDK?
Ans:- JDK stands for Java  Development Tool Kit contains various library  classes which in turn possess different packages.
Q27.Name any two version of JDK?
Ans: Two version of JDK are
1. JDK1.0(Oldest)
2. JDK 8  or JDK 9(Latest)
Q28. What are Compilers?
Ans: Compiler are the soft wares  which converts the complete program to byte code
 [Source Code(Code in High Level Language)->Byte Code(Code in 0101010)]
Like Turbo C or Turbo C++ for (C and C ++ Language)
and JDK for Java Language
Q29.What are Interpreters?
Ans: Interpreter are again software which convert line by line to machine code not the whole program.
Like MS-DOS command
Q30.Menstion  Two features of Java Language.
Ans: Two features of Java Language are
(1) Robust -WORA(Write Once and Run any Where)
(2) Java is an Object Oriented Programming Language.
Chapter 1(Introduction to classes)

LONG ANSWER TYPE QUESTIONS
Q1. How real world object implemented/represented in software terms
Ans:- The object is implemented in software terms as follows:-
1. Characteristics /attributes are implemented through member variables or data items of the object.
2. Behaviours is implemented through member functions called methods.
3. Data and methods are encapsulated into one unit and given a unique name to give it identity.
Q2. What do you mean by abstraction and encapsulation ? How are these two terms interrelated?
Or
Define Encapsulation.                                                                                                                                                                     (ICSE 2016)
Ans:-Abstraction   An abstraction is an act of representing essential features without including background details. For example an abstraction is like a switch board ,you only press certain switches according to you requirement.   
This phenomenon is called information hiding.
Encapsulation is an act of combining both data and the functions that operate on the data under a single unit. encapsulation, in a way, implements abstraction. In other words wrapping up of data and its member functions into a single unit.
Q3. Encapsulation is major properties of OOP. How is it implemented in software term?
Ans :- Encapsulation is an act of combining both data and the functions that operate on the data under a single unit. encapsulation, in a way, implements abstraction. In other words wrapping up of data and its member functions into a single unit. An object binds together its associated  functions under one unit thereby enforcing encapsulation. It means wrapping up of data and its associated functions together into a single unit.
Q4. Describe OOP's How is it advantageous over conventional POP?
Ans: -:- POP is a Procedural oriented language. In this system of programming the stress is on function other than data. Data keep floating through out the program. Hence, to rectify any error you may need to scan the whole program from beginning to end.
On the other hand, OOP stresses data rather than function. The data is confined and used with in the specified part of the program. Errors caused can be rectified by scanning specific pat of the program only.
Q5. Mention four features f OOP's. 
Ans: -Four Features of OOP's are:-
1. It gives stress on data rather than  procedures.
2. The object can be used as a  bridge to have data flow from one function to another.
3. It makes the program simple by dividing into a number of objects.
4. Data can easily be modified without any change in the function.
Q6. Name four basic principles of OOP.
Ans:- Four basic principles of OOP are:-
1)Object :- An instance of a class
2)Class: - A prototype definition having Data Members and Member Methods
3) Encapsulation:- Encapsulation is an act of combining both data and the functions that operate on the data under a single unit.
4) Abstraction:- An abstraction is an act of representing essential features without including background details.
Q7.Mention Four Features of Blue J.
Ans:- Four Features of Blue J are:-
1) Windows based platform
2) Provides a sample program as it is activated.
3) Menu Driven Approach.
4) Comparatively easier to use as compared to JDK.
Q8.Diffferentiate b/w Byte Code and Source code.
Ans: Source code is the program developed in java Language, which is input to a computer through keyboard.
Compiler converts source code to Byte Code.
Source code is written in any High Level Language(C, C++ and Java)
Where as Byte Code is a machine convertible code done by Compiler of any Language.
Q9. Distinguish b/w Java Application and Java Applet.
Ans: Java Application is a program developed by user (in and High Level languages) where Java Applets are downloaded from Internet(or Internet based programs embedded in HTML page).
Q10. Write down historical evolution of JAVA.
Ans:-Java is an Object Oriented Programming Language, developed by Sir James Gosling at Sun Micro System. This language was initially called Oak (Named after tree outside Gosling' s Office) >Later the language was professionally named by Java.
Q11. How is a class referred to as abstract Data Type.
Ans: Abstraction is an act of representing essential features without including background details. A class deals with the data through functions. The data follows the features of abstraction in its termed as abstract data type.  
Q12. "Encapsulation promotes data hiding". Comment.
Ans: Encapsulation is a feature to wrap data and function together as a unit in such a way that the data members are only applied within the functions. These data members are not accessed outside the class. Hence, it is promoted data hiding.
Q13. Mention four benefits of OOP's.
Ans: Four benefits of OOP's are:-
1) Use of existing class can be extended through inheritance.
2) Using data hiding can be generate secured program concepts.
3) Modular programming approach can be generated through objects.
4) Highly beneficial to solve complex problems.
Q14. Definition of class by code:
class ABC
{
//Data Members
int a, b, c;
double v1, v2, v3;
char ch1, ch2, ch3;
float f1, f2, f3;
// Member Methods
public void Add()
{
          //statements
}}}

Chapter 2     
DATA TYPES IN JAVA
VERY SHORT & SHORT ANSWER TYPE QUESTIONS
Q1.What do you mean by data type.
Ans:- It is a variable which is used throughout the programming as a constant to give meaningful result. 
Q2.What are token?
Ans:-Each individual character used in a statement is termed as tokens.
Q3. What do you mean by identifiers?
Ans Identifiers are the name given to different part of the program in other words identifiers(variables ) is the name of the memory location which contains a constant.
Q4. What do mean by assignment of a variable.
Ans: Assignment is the store a constant value to a variable.
e.g. int a=4;        char ch='@'    double b=7.78585;
Q5. How to declare a variable? Show wit the Help of and example.
Ans: Syntax to declare a variable is as follows:-
<data type><space><variable name>
e.g. int   x;
Q6. Differentiate b/w static and dynamic initialization.
Ans: When a variable is initialized with a specific constant before its use in the Operation it is termed as static initialization whereas, a variable which is initialized with the outcome of any function is known as dynamic initialization;
e.g.
//static initialization
int x=10; char ch='@'; double d=8.7478;
//dynamic initialization
int x=Math.round(8.6);  double d=Math.sqrt(3)
Q7. What do you mean by Boolean data type?
Ans: Boolean data type represents the value true or false.
Q8. What do you mean by Charter Data Type.
Ans: A character data type represents a character used in a Program. It may be an alphabet, a digit, or any special character.
Q9. What do you mean by mixed expression?
Ans: An Expression, which means contains values of different data types is known as mixed expression.
Q10. Arrange the following according to ascending order of their usage.  long, double, char, float, int.
Ans: char, int, long, float, double.
Q11. What do you mean by coercion ?
Ans: Implicit type conversion in which the data gets converted by default to its higher type with out any intervention of the user is called coercion.
Q12. What do you mean by library package.
Ans: A package is a collection of Classes, e.g. java.io, java.lang, java.util etc.
Q13.What is the function to round a given fractional number?
Ans: Math.round(4.9);  p is a variable whose value is to be round.
Q14. What is the function to find absolute value ?
Ans: Math.abs(-266);
Q15. Differentiate between 'A' and "A".
Ans: 'A' is a character and "A" is a String.
Q16. Differentiate between "true"  and true.
Ans: "true" is enclosed under double quotes is a string 'literal' where are true with out quotes is a boolean lieral.
Q17. Why is need of using data type?
Ans: Compiler allocates memory for the storage of data. It must know in advance .how much space has to be presented for a specific value. Hence it is needed to declare a variable of specific type.
Q18. What are tokkens?
Ans: a token is an object that represents something else, such as another object (either physical or virtual), or an abstract concept as, for example, a gift is sometimes referred to as a token of the giver's esteem for the recipient. In computers, there are a number of types of tokens.
Q19. Mention different types of tokens used in java.
Ans: The Tokens are classified as follows:-
Literals
Integer Literal int x=10   "10" is Integer Literal..
String Literal  str="Hello" "Hello" is a String Literal.
char Literal char ch='@'  '@' is character Literal.
double   double d=8.278;      8.278 is Double Literal.
float float ft=9.78;            9.78 is float literal
long lg=8437473;          8437473 is long Lieral.
short short sht=87;        87 is Short Literal
boolean     boolean b=true   true is boolean Literal
byte     byte bt =4;     4 is byte Literal.
                    
(b) Identifiers(variables) Name given to diifferent parts of a program is called Identifiers.
(c) Operators
                        i) Relational Operators(>, <, >=, <=, !=)
                        ii) Mathematical Operators(+,-,*,/,%)
                        iii) Ternary Operators(?)
                        iii) Unary Operators(& | !=).
                        iv) Binary Operators(&&, ||, <>)
                        v)                                           
(d) Separators {} [] ()
(e) Punctuators . ; :
Q20. Distinguish b/w Implicit and Explicit type conversion.
Ans: In a mixed expression the data type get converted automatically to its higher type without any intervention of the user. It is called implicit type conversion.
e.g. int a, char b;
int c=a+b;
Sum will be converted into int type.
Inexplicit type conversion the data type get converted to another type based on user's intervention.
int a; char b;
char c=(char)a+b;
Here result obtained will be character type.
Q21. What are the rule of Naming variable?
Ans:
Rules for naming variable are:-
1) The variable may have any number of characters.
2) It may contains it may contains alphabets, Numbers and characters.
3) The underscore may be applied in between the character to increase the length of a variable.
4) Variable name should meaningful which can be easily depict the logic.
Q22. What are Data Types.
Or
Distinguish between Primitive and Non-Primitive Data Type.
Ans: Primitive data types are the fundamental data types which are independent.
e.g. int, char, float, double.
Non Primitive or reference data types are derived data types which originated from Primitive Data type.
e.g. class, array,  interface, etc.
Q23. Write down the data types of the following :
(a) Whole Number                             (b) Long Integer
(c) Fractional Number                      (d) A CapitalLetter
Ans:
(a) int                                                           (b) long
(c) float or double                              (d) char
Q24. Write  down the data types of the following:-
(a) To find the square root of x.
(b) To find round of number n.
(c) To find out x raised to the power y.
(d) To find absolute number of p.
Ans:-
(a) Math.sqrt(x)
(b) Math.round(n)
(c) Math.pow(x,y)
(d) Math.abs(p)
Q25 Indicate whether the following variables are valid or Invalid.
(a) Name    (b) 42Pay  (c) ABC4CG (d) Pay-to-date (e) delhi-6
Ans: (a) Valid (b) Invalid  (c) Invalid  (d) Valid  (e) Valid
Q26. Give reasons for the following invalid variable names.
(a) xy,pq     (b)  a+b       (c) 14 years (d) cd7p
Ans:
(a) comma is not allowed in between
(b) + operator canot be used.
(c) 14 as digits cannot be used as variable name.
(d) Digit 7 is not applicable in between the character.
POINTS TO REMEMBER CHAPTER 1
1. OOPs stands for Object Oriented Programming System.
2. In OOP's stress is laid on data rather than functions.
3. OOP's support modular programming approach.
4. C++, Java, Small talk, Stimula-67, Effilel are some object oriented programming language.
5. Object is an entity, which possesses some characteristics and  behaviour.
6. Class is a collection of similar objects.
7. Each object of a class contains same attributes and behaviours.
8. Wrapping up data and function in to a single unit is called Encapsulation.
9. Encapsulation promotes data hiding and data abstraction facilitates OOP's(class object, inheritance encapsulation, Dynamic Binding Message Passing).
10. A class uses the property of Abstraction; hence it is also called Abstract Data Type.
11. Class contains various primitives data types. Hence, it is known as Composite Data type.
12. A property according to which an object of a class can acquire some characteristics from object of another class is known as Inheritance.
13.  Reusability is the process of adding some additional features to a class without modifying its contents. It can be attained through Inheritance.
14. Polymorphism is the principle of OOP, which allows function to be used for more than one purpose.
15. Polymorphism can be produced through Function Overloading.
16. Dynamic Binding is the process to link a function Overloading.
17. Java Language is developed by James Gosling at Sun Micro System, USA.
18. Initially java was named as Oak (named after Oak tree outside Gosling's Office.
19. Java uses compiler as well as interpreter.
20. Java programming can be done in two ways viz., Java Application and Java Applet.
21. Java language in case sensitive, robust, platform independent and secure.
22. Java Compiler convert Java Source Code to Byte Code.
23. Java Interpreter convert byte code to machine code, suitable to a specific.
24. JDK stands for Java Development  Tool Kit, contains various library classes which in platform.
25. Reserved Words or key words are those words, which are reserved for the system and cannot be used as variable names.
26. Comment Statements  are used in a program to indicate that the action is being taken in a programming step.
27. There are two versions of Java i.e., JDK 1.3/JDK 1.5 and Blue J JDK 1.3 is DOS based where as Blue  J is Windows based platform.
28. Blue J is the product of Monash University Southern Denmark.



POINTS TO REMEMBER CHAPTER 2
1. Types of data used for storage in memory is called Data type.
2. Tokens is referred as each individual charcter available in Java Statement.
3. Literals are constants which remains unchanged throughout the discussion of a program
4. Identifiers is a variable which can depending upon circumstances or problems.
5. Punctuators refer to the punctuation signs like "", ' ', :,; etc
6. Literals are four types Integer, Real, Character abd String.
7. Fundamentals data type such as int, float, char, double etc are called Primitive data type.
8. Non Primitive data types are derived from primitives data types e.g. class, array & interface.
9. Boolean is a specific data type which represents true or false.
10. Pure expression contains data of similar types.
11. Mixed Expressions Contains Different types of data.
12. Type casting is the process to convert a data type to another from as per user intervention or demand.
13. A Package is a collection of classes.

                       ___________________________












Class X: Java Programming
LOOPING [Pattern Printing]
Program 1: Print the following Pattern
(a)
                *
                **
                ***
                ****
                *****
                ******
Solution:
class Pattern1
{
       public static void main(String args[])
       {
                int i, j;
                for(i=1;i<7;i++)
                {
                                for(i=1;i<7;i++)
                                {
                                System.out.print("*");
                                }
                                System.out.println();
                }      
}
}
(b)
                1
                13
                135
                1357
                13579
               
Solution:
class Pattern2
{
       public static void main(String args[])
       {
                int i, j,x=1;
                for(i=1;i<7;i++)
                {                 x=1;
                                for(i=1;i<7;i++)
                                {
                                System.out.print(x);
                                x=x+2;
                                }
                                System.out.println();
                }      
}
}
(c)
                2
                24
                246
                2468
               
Solution:
class Pattern3
{
       public static void main(String args[ ])
       {
                int i, j,x=2;
                for(i=1;i<5;i++)
                {                 x=2;
                                for(i=1;i<7;i++)
                                {
                                System.out.print(x);
                                    x=x+2;
                                }
                                System.out.println();
                }      
}
}
(d)
                1
                22
                333
                4444
                55555
                666666
Solution:
class Pattern4
{
       public static void main(String args[])
       {
                int i, j;
                for(i=1;i<7;i++)
                {
                                for(j=1;j<=i; j++)
                                {
                                System.out.print(j);
                                }
                                System.out.println();
                }      
}
}
(e)
                1
                21
                321
                4321
                54321
                654321
Solution:-
class Pattern5
{
       public static void main(String args[])
       {
    int i, j;
    for(i=1;i<=6;i++)
    {
        for(j=i; j>0;j--)
        {
        System.out.print(j);
        }
        System.out.println();
    }      
    }
}






Comments

Popular posts from this blog

NOTE FOR JAVA BY MUKUL SINHA SIR