please follow and add a comment of you language (no bad words)
1. Name the programming technique that implements programs as an organised collection of
interactive objects.
a. Procedure Oriented Programming b. Modular Programming
c. Object Oriented Programming d. None of these
Ans. c. Object Oriented Programming
2. Name the characteristics of Object Oriented Programming that hides the complexity and
provides a simple interface.
a. Encapsulation b. Polymorphism
c. Abstraction d. Inheritance
Ans. c. Abstraction
3. Which among the following operator is used to access individual members of an object?
a. . (dot) b. + (plus)
c. – (minus) d. / (divide)
Ans. a. . (dot)
4. Which among the following modifier is used in a ‘class’?
a. public b. default
c. Both a and b d. None of these
Ans. c. Both a and b
hhhhhhhhhhhhhhhhh
5. Which among the following is a valid class name?
a. Simple Interest b. SimpleInterest
c. 1SimpleInterest d. Simple@Interest
Ans. b. SimpleInterest
6. Which among the following is a valid object name?
a. obj1 b. 1obj
c. Obj 1 d. Obj#1
Ans. a. obj1
7. Which among the following is a valid float literal?
a. 12.36f b. 12.36F
c. 12.36 d. Both a and b
Ans. d. Both a and b
8. Which among the following is a valid octal integer literal?
a. 0178 b. 675
c. 0675 d. 0X675
Ans. c. 0675
9. Which among the following is a valid method of initialising?
a. boolean f=true; b. boolean f=True;
c. boolean f=’true’; d. None of these
Ans. a. boolean f=true;
10. Which among the following is not a punctuator?
a. ; semicolon b. , comma
c. : colon d. . dot
Ans. d. . dot
11. Which among the following is not a primitive data type?
a. int b. float
c. String d. char
Ans. c. String
12. What is the largest possible value that can be stored in short data type?
a. 215-1 b. 231-1
c. 27-1 d. 263-1
Ans. a. 215-1
13. If a is of type int and b is of type float what would be the resultant data type of a+b?
a. int b. float
c. double d. short
Ans. b. float
B. State whether the following statements are True (T) or False (F).
1. Encapsulation refers to the art of hiding the complexities and giving a simple interface. F
2. Procedure Oriented Language follows top down approach. T
3. Java is an example of Object Oriented Language. T
4. Hiding the complexity and giving a simple interface is called Inheritance. F
5. Abstraction is same as encapsulation. F
6. An object is called a class factory. F
7. A class is an instance of an object. F
8. A class is a mechanism to implement encapsulation. T
9. Data members in a class is used to represent the characteristic of an object. T
10. The new operator is used to create an object. T
11. It’s a rule to have a class-name beginning in capital letter. F
C. Fill in the blanks.
1. A class is a template that binds together data and methods together.
2. The values in the attributes of an object is called the state of an object.
3. The dot operator is used to access the individual members of a class.
4. The keyword new is used to allocate memory space for an object.
5. The default and public access modifier is used with a class.
6. An object is an identity with certain characteristic and behaviour.
7. The values/attributes of the characteristics of an object are called the state of an object.
8. All the complexities of a program should be encapsulated in such a way so that abstraction is
obtained.
9. Inheritance allows us to encompass the parent class’ state and behaviours into its child..
10. Poly-means many and Morphism means forms.
Section A
Answer the following questions:
1. How are objects implemented in software?
Ans. In a software the characteristics of an object are represented through data members and
behaviour is represented through member functions.
2. What is abstraction? How is encapsulation related to it?
Ans. Abstraction is a principle of Object Oriented Programming (OOP) that hide certain details and
only show the essential features of the object.
3. Define Encapsulation.
Ans. Encapsulation is a principle of Object Oriented Programming (OOP) that binds together
characteristics and behaviour of an object into a single unit represented by a class.
4. What is Inheritance?
Ans. Inheritance is the concept that when a class of objects is defined, any subclass that is defined
can inherit the definitions of one or more general classes.
5. What is Object Oriented Programming?
Ans. Object Oriented Programming (or OOP) is a technique of implementing programs which are
organized as a co-interactive collection of objects, each of which represents an instance of a
class.
6. State three differences between Procedure Oriented Language and Object Oriented Languages.
Ans.
Procedure Oriented Programming
:A large program is divided into smaller segments or procedures.
:More importance is given to the program rather than the data.
:It follows top down approach.
Object Oriented Programming
:A program is represented as an object.
:More importance is given to the data rather than the program.
:It follows bottom up approach.
7. State the four characteristics/principles of Object Oriented Programming.
Ans. Encapsulation, Abstraction, Polymorphism and Inheritance.
8. What are keywords? Give an example.
Ans. A keyword is a reserved word that has a special significance to the compiler and cannot be used
anywhere else other than what it is intended for. Example- for, if, else, while etc.
9. What are identifiers?
Ans. Identifiers are the names of variables, methods, classes, packages and interfaces.
10. What is a literal?
Ans. Literal is a constant value that can be assigned to a variable.
11. Why is an object called an instance of a class?
Ans. An object is called an instance of a class as every object created from a class gets its own instances
of the variables defined in the class. Multiple objects can be created from the same class.
12. Write one difference between primitive data type and composite data type.
Ans.
Fundamental data type Composite data type These are inbuilt data type provided by the Java Language.
The size of it is fixed.
These data types are available in all parts of a program within a class.
Composite data type
These are data types created by the user using fundamental or user defined data type or both.
The size of different user-defined data type depends upon the size of the individual components of it.
These data types are available only as specified by the access specifiers.
13. Give one example each of primitive data type and composite data type.
Ans. Primitive data type: int, short, boolean, char etc.
Composite data type: class, arrays, interface etc.
15. Give one point of difference between unary and binary operators.
Ans. Unary operator works on a single operand and Binary operator works on 2 operands.
16. What do you understand by type conversion?
Ans. Type conversion is the process of converting one Primitive data type to another primitive data
type. It may be done either implicitly or explicitly.
17. State the difference between a Boolean literal and a character literal.
Ans. A boolean literal consist of only two values i.e. true or false. A character literal on the other
hand is any character enclosed within single quotes.
18. Identify the literals as given below:
i. 0.5 ii. ‘A’ iii. false iv. “a”
Ans. i. double ii. char iii. boolean iv. String
19. Which two access specifier is used in a class declaration?
Ans. public and default
20. Why is a class called an object factory?
Ans. A class is called an object factory because objects are created from a class. An object is an
instance of a class.
21. Evaluate the value of n if the value of p=5 and q=19:
int n = (q-p)>(p-q)?(q-p):(p-q);
Ans. n=14
22. What is meant by precedence of operators?
Ans. When several operations occur in an expression, each part is evaluated and resolved in a
predetermined order called operator precedence.
23. What is Operator Associativity?
Ans. Operator associativity of an operator is a property that determines how operators of the same
precedence are grouped in the absence of parentheses; i.e. in what order each operator is
evaluated when two operators of same precedence appear in an expression.
24. State the difference between an accumulator and counter.
Ans. Accumulator is a variable that is used to add or accumulate a list of items. Counter on the other
hand is a variable, which is used to keep track of the number of times an operation is being
performed.
25. What does a class encapsulate?
Ans. A class encapsulates characteristics represented by data member and behaviour represented by
member methods.
26. State the Java concept that is implemented through:
i. A super class and a sub-class.
ii. The act of representing essential features without including background details.
Ans. i. Inheritance
ii. Abstraction
27. Write a statement in Java that will declare an object named si of the SimpleInterest class.
Ans. SimpleInterest si = new SimpleInterest();
28. Rewrite the following program after removing the errors, underlining each correction:
class My Class
{
int a, b;
void initialize( )
{
a=5;
b=6;
}
void show ( )
{
System.out.println (a+ ‘’ ‘’ + b);
}
static void main( )
{
My Class ob = new My Class ( );
ob. initialize ( );
show ( ). ob;
}
}
Ans. class MyClass
{
int a, b;
void initialize( )
{
a=5;
b=6;
}
void show ( )
{
System.out.println (a+ ‘’ ‘’ + b);
}
static void main( )
{
MyClass ob = new MyClass( );
ob. initialize( );
ob.show ( );
}
}
29. Which among the following are invalid class names in Java? State with reasons.
i. Compound Interest ii. 1MyClass iii. MyClass$ iv. Myclass#
v. My@Class
Ans. i. Invalid, as a variable name cannot have a blank space.
ii. Invalid, as a variable name cannot begin with a digit.
iv. Invalid, as a variable name cannot have a special character, like #.
v. Invalid, as a variable name cannot have a special character, like @.
9 Revision Tour I
30. What is the resultant data type of the following mathematical expression?
a+b*c-d
a. where a is int, b is int, c is float and d is float type
b. where a is float, b is long, c and d is of int type
c. where a is of double and b,c and d are of int type
d. where a is char and b,c and d are of int type
e. where a, b, c and d are of int type, however the expression is slightly modified as (a+b*c-d)/7.0
Ans. a. float
b. float
c. double
d int
e. double
1. Name the programming technique that implements programs as an organised collection of
interactive objects.
a. Procedure Oriented Programming b. Modular Programming
c. Object Oriented Programming d. None of these
Ans. c. Object Oriented Programming
2. Name the characteristics of Object Oriented Programming that hides the complexity and
provides a simple interface.
a. Encapsulation b. Polymorphism
c. Abstraction d. Inheritance
Ans. c. Abstraction
3. Which among the following operator is used to access individual members of an object?
a. . (dot) b. + (plus)
c. – (minus) d. / (divide)
Ans. a. . (dot)
4. Which among the following modifier is used in a ‘class’?
a. public b. default
c. Both a and b d. None of these
Ans. c. Both a and b
hhhhhhhhhhhhhhhhh
5. Which among the following is a valid class name?
a. Simple Interest b. SimpleInterest
c. 1SimpleInterest d. Simple@Interest
Ans. b. SimpleInterest
6. Which among the following is a valid object name?
a. obj1 b. 1obj
c. Obj 1 d. Obj#1
Ans. a. obj1
7. Which among the following is a valid float literal?
a. 12.36f b. 12.36F
c. 12.36 d. Both a and b
Ans. d. Both a and b
8. Which among the following is a valid octal integer literal?
a. 0178 b. 675
c. 0675 d. 0X675
Ans. c. 0675
9. Which among the following is a valid method of initialising?
a. boolean f=true; b. boolean f=True;
c. boolean f=’true’; d. None of these
Ans. a. boolean f=true;
10. Which among the following is not a punctuator?
a. ; semicolon b. , comma
c. : colon d. . dot
Ans. d. . dot
11. Which among the following is not a primitive data type?
a. int b. float
c. String d. char
Ans. c. String
12. What is the largest possible value that can be stored in short data type?
a. 215-1 b. 231-1
c. 27-1 d. 263-1
Ans. a. 215-1
13. If a is of type int and b is of type float what would be the resultant data type of a+b?
a. int b. float
c. double d. short
Ans. b. float
B. State whether the following statements are True (T) or False (F).
1. Encapsulation refers to the art of hiding the complexities and giving a simple interface. F
2. Procedure Oriented Language follows top down approach. T
3. Java is an example of Object Oriented Language. T
4. Hiding the complexity and giving a simple interface is called Inheritance. F
5. Abstraction is same as encapsulation. F
6. An object is called a class factory. F
7. A class is an instance of an object. F
8. A class is a mechanism to implement encapsulation. T
9. Data members in a class is used to represent the characteristic of an object. T
10. The new operator is used to create an object. T
11. It’s a rule to have a class-name beginning in capital letter. F
C. Fill in the blanks.
1. A class is a template that binds together data and methods together.
2. The values in the attributes of an object is called the state of an object.
3. The dot operator is used to access the individual members of a class.
4. The keyword new is used to allocate memory space for an object.
5. The default and public access modifier is used with a class.
6. An object is an identity with certain characteristic and behaviour.
7. The values/attributes of the characteristics of an object are called the state of an object.
8. All the complexities of a program should be encapsulated in such a way so that abstraction is
obtained.
9. Inheritance allows us to encompass the parent class’ state and behaviours into its child..
10. Poly-means many and Morphism means forms.
Section A
Answer the following questions:
1. How are objects implemented in software?
Ans. In a software the characteristics of an object are represented through data members and
behaviour is represented through member functions.
2. What is abstraction? How is encapsulation related to it?
Ans. Abstraction is a principle of Object Oriented Programming (OOP) that hide certain details and
only show the essential features of the object.
3. Define Encapsulation.
Ans. Encapsulation is a principle of Object Oriented Programming (OOP) that binds together
characteristics and behaviour of an object into a single unit represented by a class.
4. What is Inheritance?
Ans. Inheritance is the concept that when a class of objects is defined, any subclass that is defined
can inherit the definitions of one or more general classes.
5. What is Object Oriented Programming?
Ans. Object Oriented Programming (or OOP) is a technique of implementing programs which are
organized as a co-interactive collection of objects, each of which represents an instance of a
class.
6. State three differences between Procedure Oriented Language and Object Oriented Languages.
Ans.
Procedure Oriented Programming
:A large program is divided into smaller segments or procedures.
:More importance is given to the program rather than the data.
:It follows top down approach.
Object Oriented Programming
:A program is represented as an object.
:More importance is given to the data rather than the program.
:It follows bottom up approach.
7. State the four characteristics/principles of Object Oriented Programming.
Ans. Encapsulation, Abstraction, Polymorphism and Inheritance.
8. What are keywords? Give an example.
Ans. A keyword is a reserved word that has a special significance to the compiler and cannot be used
anywhere else other than what it is intended for. Example- for, if, else, while etc.
9. What are identifiers?
Ans. Identifiers are the names of variables, methods, classes, packages and interfaces.
10. What is a literal?
Ans. Literal is a constant value that can be assigned to a variable.
11. Why is an object called an instance of a class?
Ans. An object is called an instance of a class as every object created from a class gets its own instances
of the variables defined in the class. Multiple objects can be created from the same class.
12. Write one difference between primitive data type and composite data type.
Ans.
Fundamental data type Composite data type These are inbuilt data type provided by the Java Language.
The size of it is fixed.
These data types are available in all parts of a program within a class.
Composite data type
These are data types created by the user using fundamental or user defined data type or both.
The size of different user-defined data type depends upon the size of the individual components of it.
These data types are available only as specified by the access specifiers.
13. Give one example each of primitive data type and composite data type.
Ans. Primitive data type: int, short, boolean, char etc.
Composite data type: class, arrays, interface etc.
15. Give one point of difference between unary and binary operators.
Ans. Unary operator works on a single operand and Binary operator works on 2 operands.
16. What do you understand by type conversion?
Ans. Type conversion is the process of converting one Primitive data type to another primitive data
type. It may be done either implicitly or explicitly.
17. State the difference between a Boolean literal and a character literal.
Ans. A boolean literal consist of only two values i.e. true or false. A character literal on the other
hand is any character enclosed within single quotes.
18. Identify the literals as given below:
i. 0.5 ii. ‘A’ iii. false iv. “a”
Ans. i. double ii. char iii. boolean iv. String
19. Which two access specifier is used in a class declaration?
Ans. public and default
20. Why is a class called an object factory?
Ans. A class is called an object factory because objects are created from a class. An object is an
instance of a class.
21. Evaluate the value of n if the value of p=5 and q=19:
int n = (q-p)>(p-q)?(q-p):(p-q);
Ans. n=14
22. What is meant by precedence of operators?
Ans. When several operations occur in an expression, each part is evaluated and resolved in a
predetermined order called operator precedence.
23. What is Operator Associativity?
Ans. Operator associativity of an operator is a property that determines how operators of the same
precedence are grouped in the absence of parentheses; i.e. in what order each operator is
evaluated when two operators of same precedence appear in an expression.
24. State the difference between an accumulator and counter.
Ans. Accumulator is a variable that is used to add or accumulate a list of items. Counter on the other
hand is a variable, which is used to keep track of the number of times an operation is being
performed.
25. What does a class encapsulate?
Ans. A class encapsulates characteristics represented by data member and behaviour represented by
member methods.
26. State the Java concept that is implemented through:
i. A super class and a sub-class.
ii. The act of representing essential features without including background details.
Ans. i. Inheritance
ii. Abstraction
27. Write a statement in Java that will declare an object named si of the SimpleInterest class.
Ans. SimpleInterest si = new SimpleInterest();
28. Rewrite the following program after removing the errors, underlining each correction:
class My Class
{
int a, b;
void initialize( )
{
a=5;
b=6;
}
void show ( )
{
System.out.println (a+ ‘’ ‘’ + b);
}
static void main( )
{
My Class ob = new My Class ( );
ob. initialize ( );
show ( ). ob;
}
}
Ans. class MyClass
{
int a, b;
void initialize( )
{
a=5;
b=6;
}
void show ( )
{
System.out.println (a+ ‘’ ‘’ + b);
}
static void main( )
{
MyClass ob = new MyClass( );
ob. initialize( );
ob.show ( );
}
}
29. Which among the following are invalid class names in Java? State with reasons.
i. Compound Interest ii. 1MyClass iii. MyClass$ iv. Myclass#
v. My@Class
Ans. i. Invalid, as a variable name cannot have a blank space.
ii. Invalid, as a variable name cannot begin with a digit.
iv. Invalid, as a variable name cannot have a special character, like #.
v. Invalid, as a variable name cannot have a special character, like @.
9 Revision Tour I
30. What is the resultant data type of the following mathematical expression?
a+b*c-d
a. where a is int, b is int, c is float and d is float type
b. where a is float, b is long, c and d is of int type
c. where a is of double and b,c and d are of int type
d. where a is char and b,c and d are of int type
e. where a, b, c and d are of int type, however the expression is slightly modified as (a+b*c-d)/7.0
Ans. a. float
b. float
c. double
d int
e. double
Comments
Post a Comment