CH 6-7 Computer Assignment - Solution
CH 6-7 Computer Assignment - Solution
1. What is class-diagram?
(A) Diagrams (B) Steps (C) Symbols (D) Data-diagram
Ans. : Diagrams
2. We have written a function named ‘Max’ that takes two integers as parameters
and returns maximum as integer value and one more function named ‘Max’ that
finds maximum of integer elements stored in an array. What is known as this
creation?
(A) Polymorphism (B) Encapsulation (C) a and b both (D) None of these.
Ans. : Polymorphism
3. Object-oriented programming allows to define more than one method having
same name but different signatures in a single class. What is known as this
characteristic?
(A) Function (B) Method overloading
(C) a or b (D) None of these
Ans. : a or b
4. Which of the following object-oriented programming allows writing expression
using operators?
(A) Object (B) Class (C) Function (D) Template
Ans. : Object
5. In object-oriented programming same operation is given different meanings
depending upon the data type of operands used. By what can this type of
Polymorphism be achieved?
(A) Operator overloading (B) Aggregation
(C) Data-Abstraction (D) Encapsulation
Ans. : Operator overloading
6. By which of the following overloading is polymorphism possible?
Page 1
(A) Operator overloading (B) Function overloading
(C) a and b both (D) None of these
Ans. : a and b both
7. What is called the capability of using same names to mean different things in
different context in general?
(A) Overloading (B) Aggregation (C) Composition (D) Encapsulation
Ans. : Overloading
8. What is called when objects of one class are composed of other class?
(A) Aggregation (B) Composition (C) a or b (D) Overloading
Ans. : a or b
9. Which relationship does aggregation or composition represent between
different classes?
(A) has-a (B) a-part-of (C) a or b (D) None of these
Ans. : a or b
10. A computer screen is a class with following attribute?
(A) length (B) width (C) model (D) All of these
Ans. : All of these
11. Which attributes will a class contain when we define a class ‘computer’?
(A) Motherboard (B) Screen (C) a and b both (D) None of these
Ans. : a and b both
12. In which of the following can the class that forms part of the owner class exist
independently?
(A) Aggregation (B) Polymorphism (C) Encapsulation (D) Abstraction
Ans. : Aggregation
13. In which of the following is the life of an object of the part class not determined
by the owner class?
(A) Aggregation (B) Polymorphism (C) Encapsulation (D) Abstraction
Ans. : Aggregation
14. With which symbol is aggregation represented in class-diagram?
(A) Symbol of an empty diamond
(B) Symbol of a filled diamond
(C) Symbol of an empty triangle
(D) Symbol of a filled diamond
Ans. : Symbol of an empty diamond
Page 2
15. What is known as the class when it contains object of other class?
(A) Owner Class (B) Whole Class
(C) Aggregating Class (D) All of these
Ans. : All of these
16. What is known as the class when it is contained in owner class?
(A) Subject Class (B) Part Class
(C) Aggregated Class (D) All of these
Ans. : All of these
17. Which class is an example of aggregating class when Person class has Name
and Address class?
(A) Person (B) Address (C) Name (D) All of these
Ans. : Person
18. Which class is an example of aggregated class when Person class has Name and
Address class?
(A) Person (B) Address (C) Name (D) b & c both
Ans. : Inheritance
20. Which of the following refers to the capability of defining a new class of objects
that inherits the characteristics of another existing class?
(A) Aggregation (B) Inheritance (C) Composition (D) Encapsulation
Ans. : Inheritance
21. Which relationship is appropriate when one class is a kind of other class?
(A) ‘is - a - kind - of’ (B) ‘multi - kind - of’
(C) ‘multilevel - kind - of’ (D) None of these
Page 3
Ans. : Super
24. Which feature provides reusability where existing methods can be reused
without redefining?
(A) Aggregation (B) Inheritance (C) Composition (D) Encapsulation
Ans. : Aggregation
25. “Inheritance allows the methods to be redefined in subclass as per need.”
Specify this statement.
(A) This statement is true. (B) This statement is false.
(C) It depends on object. (D) It depends on class
Ans. : super
27. Which of the following is an example of multilevel inheritance?
(A) Person - Employee -Teacher
(B) Computer - Mother board -Model
(C) a and b both
(D) None of these
Page 4
31. In which of the following classes do not inherit from other classes, but are
composed of other classes?
(A) Inheritance (B) Aggregation (C) Polymorphism (D) All of these
Ans. : All of these
32. By which of the following is class made in composition?
(A) By other class (B) Inherited (C) A or B (D) None of these
Ans. : Class
37. Which of the following together can a class encapsulate as a template that can
be shared by all objects?
(A) Attribute (B) Method (C) a and b both (D) None of these
Ans. : a and b both
38. Which of the following are distinguished by their state?
(A) Class (B) Object (C) Data (D) Field
Ans. : Object
39. For which of the following values of attribute more than one class may be
associated with each other?
(A) Class (B) Object (C) Data (D) Field
Ans. : Object
Page 5
40. What is a relationship called when there is ‘has- a’ or ‘a-part-of’ relationship
between two classes?
(A) Aggregation (B) Composition (C) a or b (D) Polymorphism
Ans. : a or b
41. Which of the following represents non-exclusive relationship between two
classes?
(A) Aggregation (B) Composition (C) Encapsulation (D) Polymorphism
Ans. : Aggregation
42. Which type of features are implemented in superclass in inheritance?
(A) Common (B) Special (C) a and b both (D) None of these
Ans. : Common
43. Which type of features are implemented in subclass in inheritance?
(A) Common (B) Special (C) a and b both (D) None of these
Ans. : Special
44. In Object-oriented methodology, the focus is on which of the following entities?
(A) Data (B) Functions (C) Objects (D) All of these
Ans. : (C) Objects
45. Which of the following best suits to Java ?
(A) A procedural programming language
(B) An Object-oriented programming language
(C) A Query language
(D) All of these
Ans. : (B) An Object-oriented programming language
46. Which of the following is enabled by data abstraction?
(A) Data protection
(B) Data hiding
(C) To hide implementation details of method manipulating the data
(D) All of the above
Ans. : (C) To hide implementation details of method manipulating the data
47. An inheritance model refers to which of the following relationships?
(A) is-a' relationship (B) has-a' relationship
(C) a-part-of' relationship (D) All of these
Ans.: (A) is-a' relationship
48. In which year the object-oriented programming concepts started originating?
Page 6
(A) 1990s (B) 1980s (C) 1960s (D) 1970s
Page 7
Ans.: (A) Abstraction
58. What is the full form of ADTL ?
(A) Abstract Data Types (B) Abstraction of Data Transmission
(C) Aggregation of Data Types (D) None of these
Ans.: (A) Abstract Data Types
59. Polymorphism' means....
(A) Many forms (B) A call to a method
(C) Data hiding (D) Encapsulation
Ans.: (A) Many forms
60. Which kind of programming allows defining more than one method having
same name but different signatures in a single class?
(A) Structured (B) Object-oriented (C) Procedural (D) All A, B & C
Page 8
Ans. : (D) Non-exclusive
67. Which kind of relationship is represented by composition between two classes ?
(A) Exclusive (B) is - a (C) of - a (D) Non-exclusive
Ans.: (A) Exclusive
68. With which symbol, basic aggregation is represented?
(A) Filled diamond (B) Empty diamond (C) Filled rectangle (D) Empty rectangle
Ans. : (B) -
Page 9
76. Which of the following symbol is used to represent "Protected" visibility ?
(A) # (B) ~ (C) + (D) -
Ans.: (A) #
77. Which of the following symbol is used to represent "Package" visibility ?
(A) + (B) # (C) ~ (D) -
Ans. : (C) ~
78. Which of the following is a proper syntax of UML notation ?
(A) [<method name>] <visibility> (parameter list separated by comma):<return data
type>
(B) [<visibility>] <method name> (parameter list separated by comma):<return data
type>
(C) [<visibility>] <method name> (parameter list separated by semicolon):<return data
type>
(D) [<visibility>] <method name> (parameter list separated by comma):< data >
Page 10
84. Which is a strong type of aggregation where the lifetime of the part class
depends on the existence of the owner class?
(A) Aggregation (B) Polymorphism (C) Composition (D) Inheritance
Ans. : (C) Composition
85. In class diagram, which symbol is used to represent inheritance ?
(A) An arrow pointing to subclass
(B) Two sided arrow which connect subclass and superclass
(C) An arrow pointing to superclass
(D) A single line connecting sub and superclass
Ans. : (C) An arrow pointing to superclass
86. In "is - a" relationship, which class is a specialized version with additional
attributes and methods ?
(A) Sub (B) Super (C) Abstract (D) Aggregate
Ans.: (A) Sub
87. In which of the following classes do not inherit from other classes, but are
'composed of other classes ?
(A) Inheritance (B) Polymorphism (C) Composition (D) Encapsulation
Ans. : (C) Composition
88. Which of the following can be considered as a blueprint for various objects?
(A) State (B) Attribute (C) Features (D) Class
Ans. : (D) Class
89. How objects are presented during execution of an application?
(A) Using their state (B) Using behaviour (C) Using properties (D) Using attributes
Ans.: (A) Using their state
90. Which concept hides the complexity?
(A) UML diagrams (B) Class diagrams (C) Abstraction (D) Encapsulation
Ans. : (C) Abstraction
91. Which of the following is the capability of defining a new class of objects that
inherits the characteristics of another existing class?
(A) Aggregation (B) Inheritance (C) Polymorphism (D) Encapsulation
Page 11
Ans. : (D) Attributes
93. Which of the following symbol is used to represent "Public" visibility?
(A) ~ (B) # (C) - (D) +
Ans. : D
94. Which of the following is in the bottom section of class icon?
(A) Behaviour of the class (B) Operations of the class
(C) Methods of the class (D) All A, B & C
Ans. : (D) All A, B & C
95. How many basic (primitive) data types are supported in Java ?
(A) 2 (B) 4 (C) 8 (D) 16
Ans. : (C) 8
96. What will be the result of arithmetic expression −7%2?
Page 12
Ans. : (D) Java bytecode
102. What will be the extension of file, when the program gets compiled without
errors ?
(A) .class (B) .java (C) .javaclass (D) .javac
Ans.: (A) .class
103. In Java program, which methods are used to display results?
(A) [Link] (B) [Link]
(C) Both A & B (D) printf()
Ans. : (C) Both A & B
104. Which of the following option is used to compile source program ?
(A) File → Compile (B) Tools → Compile
(C) Edit → Compile (D) Windows → Compile
Ans. : (B) Tools → Compile
105. Which option is used to execute the program, if the program is compiled
without any error ?
(A) Program→ Run (B) Run → Program (C) Tools → Run (D) Tools → Go
Page 13
Ans. : (B) 4 bytes
112. What is the storage space used by "double" data type ?
(A) 1 byte (B) 8 bytes (C) 2 bytes (D) 4 bytes
Page 14
(A) Comments (B) Datatypes (C) Variables (D) Literals
Ans. : (C) Variables
122. In syntax of variables declaration, which brackets denote the item to be
specified by user ?
(A) < > (B) { } (C) Both A & B (D) None
Ans.: (A) < >
123. In syntax of variable declaration, which brackets denote the list of items
separated by commas?
(A) < > (B) { } (C) [ ] (D) ( )
Ans. : (B) { }
124. In syntax of variable declaration, which of the following is to be replaced with
the keyword denoting the data type of the variables ?
(A) {variable-names) (B) < > (C) Semicolon (D) <type-name>
Ans. : (D) <type-name>
125. Which are the valid characters for variable name ?
(A) Any character of keyboard
(B) Alphabet, Brackets, Digits, Underscore
(C) Digits, alphabets, $, underscore
(D) Digits, alphabets, function keys, $
Ans. : (C) Digits, alphabets, $, underscore
126. Which words have special use in Java and can not be used by the programmer
for other purposes ?
(A) Variable name (B) Reserved (C) Literals (D) Class names
Ans. : (B) Reserved
127. Which term is used for variable name, when sometimes first alphabet of each
word is capitalized ?
(A) Upper case (B) Lower case (C) Toggle case (D) Camel case
Ans. : (D) Camel case
128. From the following which is the illegal name of variable in Java ?
(A) 4me (B) result (C) amounts (D) price
Page 15
Ans. : (C) BalanceAmount
130. In Java, which names begin with upper case letters ?
(A) Variable (B) Classes (C) Methods (D) Function
Ans. : (B) Classes
131. In Java, which names begin with lower case letters ?
(A) Method (B) Variable (C) Both A & B (D) Classes
Ans. : (C) Both A & B
132. What should be included with each variable declaration to explain its purpose in
the program?
(A) Curly brackets (B) Semicolon (C) Public word (D) Comments
Ans. : (D) Comments
133. How many types of variables are available in Java ?
(A) Six (B) Three (C) Five (D) Eight