0% found this document useful (0 votes)
6 views23 pages

CH 6-7 Computer Assignment - Solution

The document consists of a series of multiple-choice questions related to object-oriented programming concepts, including class diagrams, polymorphism, inheritance, encapsulation, and aggregation. Each question is followed by the correct answer, providing a comprehensive overview of key programming principles. The total marks for the assignment are 200.

Uploaded by

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

CH 6-7 Computer Assignment - Solution

The document consists of a series of multiple-choice questions related to object-oriented programming concepts, including class diagrams, polymorphism, inheritance, encapsulation, and aggregation. Each question is followed by the correct answer, providing a comprehensive overview of key programming principles. The total marks for the assignment are 200.

Uploaded by

ramawatibeauty
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Ch 6 7

STD 12 COMPUTER Total Marks : 200


Assignment

* Choose The Right Answer From The Given Options: [200]

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. : b & c both


19. Which of the following is referred to as ‘is-a- kind-of’ relationship between two
classes?
(A) Aggregation (B) Inheritance (C) Composition (D) Encapsulation

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

Ans. : ‘is - a - kind - of’


22. What is called a new class in object-oriented terminology?
(A) Subclass (B) Child class (C) Derived class (D) All of these

Ans. : All of these


23. Choose the data attributes and methods of the class that are available to objects
in the subclass without rewriting their declaration.
(A) Super (B) Sub (C) Child (D) Derived

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. : This statement is true.


26. By using arrow pointing to which class in class- diagram is inheritance
represented?
(A) super (B) Sub (C) Child (D) Derived

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

Ans. : a and b both


28. In which classes does ‘a-kind-of’ relationship exist in inheritance?
(A) Masterclass and Superclass (B) Masterclass and Subclass
(C) Superclass and Subclass (D) Subclass and Subclass

Ans. : Superclass and Subclass


29. Which type of relationship exists between superclass and subclass in
inheritance?
(A) ‘a kind of’ (B) ‘multi kind of’
(C) None of these (D) ‘different kind of’
Ans. : ‘a kind of’
30. ‘Which of the following statements is true for inheritance?
(A) Allows to share functionality of (B) Allows to reuse functionality of
class class
(C) Extend functionality (D) All of these

Ans. : All 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. : By other class


33. What is represented using class-diagram?
(A) Relationship (B) Constraints (C) a and b both (D) None of these.
Ans. : a and b both
34. In which of the following does object-oriented methodology play significant
role?
(A) Analysis of (B) Design (C) Implementation (D) All of these
software system

Ans. : All of these


35. On which of the following two does focus lie in object-oriented programming?
(A) Data and Animation (B) Networking and Animation
(C) Data and functionality (D) Animation and Functionality

Ans. : Data and functionality


36. Which of the following encapsulates attributes (data) and methods (behavior or
functionality) together as a template that can be shared by all objects?
(A) Class (B) Inheritance (C) Super object (D) Sub object

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

Ans. : (C) 1960s


49. In which of the following categories the way of programming can be divided ?
(A) Procedural (B) Object-oriented (C) Both A & B (D) None of these
Ans. : (C) Both A & B
50. How many object properties are supported by object-oriented language ?
(A) One (B) Two (C) Three (D) Four
Ans. : (D) Four
51. With which of the following properties a computer language is known as object
oriented?
(A) Abstraction, Encapsulation, Polymorphism, Inheritance
(B) Speed of development, Flexibility, Complexity, Modularity
(C) Abstraction, Reusability, Flexibility, Inheritance
(D) Encapsulation, Polymorphism, Reusability, Complexity

Ans.: (A) Abstraction, Encapsulation, Polymorphism, Inheritance


52. Which of the following describes the object ?
(A) Members (B) Attributes (C) Methods (D) Features

Ans. : (B) Attributes


53. Which of the following can be considered as a blueprint for various objects ?
(A) State (B) Attribute (C) Features (D) Class
Ans. : (D) Class
54. Which of the following is a template for multiple objects with similar features ?
(A) Class (B) Method (C) Feature (D) Properties
Ans.: (A) Class
55. Identify: "The mechanism of providing protection to data and methods of a
program".
(A) Encapsulation (B) Abstraction (C) Polymorphism (D) Hiding
Ans.: (A) Encapsulation
56. Which of the following is a process of representing the essential features of the
objects without including implementation detail?
(A) Encapsulation (B) Aggregation (C) UML diagrams (D) Data abstraction

Ans. : (D) Data abstraction


57. Which concept says what it does not how it is done?
(A) Abstraction (B) Encapsulation (C) Messaging (D) Polymorphism

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

Ans. : (B) Object-oriented


61. Object-oriented programming allows defining more than one method having
same name but different signatures in a single class is known as…
(A) Polymorphism (B) Messaging
(C) Method overloading (D) None of these

Ans. : (C) Method overloading


62. How many types of overloading is used to achieve polymorphism?
(A) One (B) Two (C) Three (D) Four
Ans. : (B) Two
63. Which of the following are types of overloading in polymorphism achievement?
(A) Function (B) Operator (C) Both A & B (D) Data
overloading overloading overloading

Ans. : (C) Both A & B


64. When objects of one class are composed of objects of other class, it is called....
(A) Messaging or Polymorphism (B) Aggregation or Composition
(C) Encapsulation or Abstraction (D) Polymorphism or Abstraction

Ans. : (B) Aggregation or Composition


65. Between classes, which kind of relationship is represented by aggregation?
(A) Has - a (B) a-part-of (C) Both A & B (D) is - a
Ans. : (C) Both A & B
66. Which kind of relationship is represented by aggregation between two classes ?
(A) Exclusive (B) is - a (C) of - a (D) Non-exclusive

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) Empty diamond


69. 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
Ans. : (D) Encapsulation
70. Which other names are available for "New class", in object-oriented
terminology?
(A) Sub class (B) Child class (C) Derived class (D) All A, B & C

Ans. : (D) All A, B & C


71. Which other names are available for "Existing class", in object-oriented
terminology?
(A) Super class (B) Parent class (C) Base class (D) All A, B & C
Ans. : (D) All A, B & C
72. Which of the following is a general concept used to embody all the common
features of a particular set of objects ?
(A) Class (B) State (C) Behaviour (D) Attribute
Ans.: (A) Class
73. Which of the following presents a collection of classes, constraints and
relationship among classes ?
(A) State diagram (B) Object class
(C) Behaviour of class (D) Class diagram
Ans. : (D) Class diagram
74. Which symbol is used to represent class in class diagram ?
(A) Circle (B) Oval (C) Rectangle (D) Square
Ans. : (C) Rectangle
75. Which of the following symbol is used to represent "Private" visibility ?
(A) # (B) - (C) + (D) ~

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 >

Ans. : (B) [<visibility>] <method name> (parameter list separated by comma):


<return data type>
79. Identify: "The mechanism of providing protection to data and methods of a
program".
(A) Encapsulation (B) Abstraction (C) Polymorphism (D) Hiding
Ans.: (A) Encapsulation
80. Which of the following is a process of representing the essential features of the
objects without including implementation detail?
(A) Encapsulation (B) Aggregation (C) UML diagrams (D) Data abstraction
Ans. : (D) Data abstraction
81. What is the full form of ADT ?
(A) Abstract Data Types (B) Abstraction of Data Transmission
(C) Aggregation of Data Types (D) None of these
Ans.: (A) Abstract Data Types
82. Identify: "A call to a method, in object-oriented terminology."
(A) Data abstraction (B) Encapsulation (C) Message (D) Aggregation
Ans. : (C) Message
83. Between classes, which kind of relationship is represented by aggregation ?
(A) Has - a (B) a-part-of (C) Both A & B (D) is - a
Ans. : (C) Both A & B

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

Ans. : (B) Inheritance


92. Which of the following can be directly mapped with object oriented languages
and widely used among software developers?
(A) Class behaviour (B) Class diagram (C) Properties (D) Attributes

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?

(A) -3 (B) -1 (C) 1 (D) -3.5


Ans. : (B) -1
97. Which of the following is an object-oriented programming language developed
by Sun Microsystems ?
(A) C language (B) BASIC (C) Java (D) FORTRAN

Ans. : (C) Java


98. Which of the following statement is true for Java language ?
(i) Java language was developed by Sun Microsystem.
(ii) Java is an object-oriented language.
(iii) Java is not platform-independent at both the source and binary level.
(A) Only (i) and (ii) (B) Only (ii) and (iii) (C) Only (i) and (iii) (D) (i), (ii) and (iii)

Ans.: (A) Only (i) and (ii)


99. Which is considered as one of the ideal language for distributing executable
programs via the World Wide Web?
(A) C language (B) Java (C) C# (D) Javascript
Ans. : (B) Java
100. What is the full form of JVM ?
(A) Java Visibility Modifier (B) Java Visual Modem
(C) Java Virtual Machine (D) Java Visual Machine
Ans. : (C) Java Virtual Machine
101. Identify: "The machine language for the Java Virtual Machine".
(A) Binary language (B) Machine language
(C) Java Machine language (D) Java bytecode

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

Ans. : (D) Tools → Go


106. Which data types are machine-independent?
(A) Array (B) String (C) Both A & B (D) Primitive
Ans. : (D) Primitive
107. What is the storage space used by "byte" data type ?
(A) 2 bytes (B) 1 byte (C) 4 bytes (D) 8 bytes
Ans. : (B) 1 byte
108. What is the storage space used by "short" data type ?
(A) 8 bytes (B) 1 byte (C) 4 bytes (D) 2 bytes

Ans. : (D) 2 bytes


109. What is the storage space used by "int" data type ?
(A) 8 bytes (B) 4 bytes (C) 2 bytes (D) 1 byte
Ans. : (B) 4 bytes
110. What is the storage space used by "long" data type ?
(A) 4 bytes (B) 1 byte (C) 2 bytes (D) 8 bytes
Ans. : (D) 8 bytes
111. What is the storage space used by "float" data type ?
(A) 1 byte (B) 4 bytes (C) 2 bytes (D) 8 bytes

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

Ans. : (B) 8 bytes


113. What is the storage space used by "char" data type ?
(A) 1 byte (B) 2 bytes (C) 8 bytes (D) 4 bytes
Ans. : (B) 2 bytes
114. What is the storage space used by "boolean" data type ?
(A) 4 bytes (B) 2 bytes (C) 8 bytes (D) 1 byte
Ans. : (D) 1 byte
115. What is the range of values for "boolean" data type ?
(A) true, false (B) -32768 to 32767
(C) 16-bit Unicode character (D) 10 ± 38 with about 7 significant
digits

Ans.: (A) true, false


116. What is the default value of Boolean data type of Java ?
(A) False (B) True (C) 0 (Zero) (D) 1
Ans.: (A) False
117. Which types of numbers are compliant with IEEE 754 standard ?
(A) Integer (B) Long (C) Real (D) Boolean
Ans. : (C) Real
118. Which of the following is an international standard for defining floating-point
numbers and arithmetic?
(A) Java (B) C++ (C) IEEE 754 (D) C#

Ans. : (C) IEEE 754


119. Identify: "A name used to refer to the data stored in memory".
(A) Variable (B) Keyword
(C) Unicode character (D) Datatype
Ans.: (A) Variable
120. Which of the following can take different values at different times during the
execution of the program but always refers to the same memory location?
(A) Keywords (B) Variable (C) Comments (D) Literals
Ans. : (B) Variable
121. Which of the following always refers to the same memory location?

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

Ans.: (A) 4me


129. Which of the following is example of Camel case ?
(A) Balance_amount (B) BALANCEaMOUNT
(C) BalanceAmount (D) balance_amount

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

Ans. : (B) Three


134. Which variables are available in Java ?
(A) Instance, class and local (B) Class, local and modular
(C) Local, Functional and procedural (D) None of these
Ans.: (A) Instance, class and local
135. Which of the following are considered as local variables ?
(A) Function parameters (B) Variables declared in the function
(C) Both A & B (D) Variables declared in the class
Ans. : (C) Both A & B
136. Which brackets denotes optional items in the variable declaration syntax <type
name> {variable [= <value>,] }; ?
(A) [ ] (B) < > (C) { } (D) ( )
Ans.: (A) [ ]
137. Which variables are not initialized with default values ?
(A) Modular (B) Local (C) Procedural (D) Functional
Ans. : (B) Local
138. Identify: "A name used for a constant value in Java".
(A) Variable (B) Identifier (C) Literal (D) Keyword

Ans. : (C) Literal


139. Which literals are used to represent integer or real numbers ?
(A) String (B) Number (C) Character (D) Boolean
Ans. : (B) Number
140. Which numeric digits are used for Hexadecimal numbers (16 digits) in integer
literals in Java ?
(A) 0 to 8 and A to E (B) 0 to 9 and A to F (C) 0 to 15 (D) 0 to 16
Ans. : (C) 0 to 15
141. Which of the following statement is right for boolean literals in Java?
(i) 0 is treated as false and 1 is treated as true.
(ii) Literals are to be typed without quotes.
(iii) For the boolean type, there are two literals true and flase.
(A) Only (i) and (ii) (B) Only (ii) and (iii) (C) Only (i) and (iii) (D) (i), (ii) and (iii)

Ans. : (B) Only (ii) and (iii)


142. What is important to make the program easy to understand for everyone?
(A) Program code (B) Class name (C) Variables (D) Comments
Ans. : (D) Comments
143. Which delimiter denotes single line comment in Java ?
(A) / / (B) /*....*/ (C) # (D) $
Ans.: (A) / /
144. Which delimiter is used for multiline comment ?
(A) % (B) $ (C) / / (D) /*....*/
Ans. : (D) /*....*/
145. Which operator is used to concatenate string ?
(A) % (B) $ (C) + (D) =
Ans. : (C) +
146. Which of the following is not a comparison operator in Java ?
(A) <= (B) >= (C) = (D) !=
Ans. : (C) =
147. Which of the following is 'not equal to' Comparison operator in Java?
(A) != (B) = = (C) < > (D) NOT
Ans.: (A) !=
148. From the following which is not a comparison operator in Java ?
(A) > (B) < (C) <= (D) +
Ans. : (D) +
149. What is the other name of Logical operators ?
(A) Boolean (B) Comparison (C) Relational (D) Arithmetic
Ans.: (A) Boolean
150. What is the other name for the Conditional operator ?
(A) Ternary (B) Logical (C) Arithmetic (D) Assignment
Ans.: (A) Ternary
151. Which symbols are used in the Conditional operator?
(A) ? and ; (B) $ and % (C) ? and : (D) - and ?
Ans. : (C) ? and :
152. What is the alias of word 'Branches'?
(A) Scope of variables (B) Block of statements
(C) Selective structures (D) Loops
Ans. : (C) Selective structures
153. Which statement is used to take one of two alternative courses of action,
depending on whether the value of a given boolean-valued expression is true or
false ?
(A) For loop (B) While loop (C) If (D) Do....while
Ans. : (C) If
154. If statement' is an example of which control structures ?
(A) Decision (B) Selective (C) Branching (D) All A, B & C
Ans. : (D) All A, B & C
155. What will be evaluated first, when if statement is executed ?
(A) Statement 1 (B) Statement 2
(C) Boolean expression (D) Public class
Ans. : (C) Boolean expression
156. Which statement block will be executed, if Boolean expression's value is true ?
(A) Statement 4 (B) Statement 3 (C) Statement 2 (D) Statement 1
Ans. : (D) Statement 1
157. Which block of statement will be executed, when Boolean expression's value is
false?
(A) Statement 1
(B) Block of statements written after keyword else
(C) Block of statements written after if statement
(D) Exit
Ans. : (B) Block of statements written after keyword else
158. When an if statement is used in another if statement, it is called....
(A) Scope of variables (B) Statement of blocks
(C) Nested-if statement (D) Loops
Ans. : (C) Nested-if statement
159. What will be the output of following program statements for x = 5 and y = -5 ?
if (x > 0)
if (y < 0)
[Link]("X and Y are Positive numbers");
else
[Link](" X is greater than Y");
(A) X is greater than Y (B) X and Y are positive numbers
(C) Y is negative number (D) Only X is positive number
Ans.: (A) X is greater than Y
160. Which of the following statement is used when there are many alternative
actions to be taken depending the value of a variable or expression?
(A) Switch (B) For (C) While (D) Do...while
Ans.: (A) Switch
161. In Switch statement, if a match is found than which statement will be executed?
(A) Default (B) Case (C) Switch (D) Exit
Ans. : (B) Case
162. In Switch statement, if a match is not found than which statement will be
executed?
(A) Default (B) Case (C) Continue (D) Exit
Ans.: (A) Default
163. Which of the following is optional ?
(A) Case (B) Default (C) Both A & B (D) None of these
Ans. : (B) Default
164. Which statement is used to jump at the first statement after the end of Switch?
(A) Case (B) Default (C) Continue (D) Break
Ans. : (D) Break
165. How many looping structures are supported by Java ?
(A) One (B) Two (C) Three (D) Four

Ans. : (C) Three


166. Which of the following are looping structures of Java ?
(A) If, For, While (B) While, For, Do...while
(C) If, Switch, For (D) For, If, Do... While
Ans. : (B) While, For, Do...while
167. Which of the following is correct syntax of for loop ?
(A) for (exp1; exp2; exp3) (statements)
(B) for (exp) {statements}
(C) for (statements) (exp);
(D) for {statements) (exp1; exp2; exp3)
Ans.: (A) for (exp1; exp2; exp3) (statements)
168. Which of the following is correct syntax of while loop ?
(A) while (exp1; exp2; exp3) {statements}
(B) while (exp) {statements}
(C) while {statements} (exp);
(D) while {statements} (exp1; exp2; exp3)
Ans. : (B) while (exp) {statements}
169. Which of the following is correct syntax of do...while loop ?
(A) do (expl; exp2; exp3) {statements}
(B) do (exp) {statements}
(C) do {statements} (exp);
(D) do {statements} (expl; exp2; exp3)
Ans. : (C) do {statements} (exp);
170. Which of following loops are entry-controlled loops ?
(A) For and while (B) While and do...while
(C) Do...while and for (D) While and if
Ans.: (A) For and while
171. What is the other name of entry-controlled constructs ?
(A) Post-test (B) Entry-test (C) Exit-test (D) Pre-test
Ans. : (D) Pre-test
172. Which loop is generally used, when number of iteration are pre-determined ?
(A) While (B) For (C) Do...while (D) If
Ans. : (B) For
173. In which loop all the three expressions are optional ?
(A) While (B) Do...while (C) For (D) Switch
Ans. : (C) For
174. Which is first expression in for loop ?
(A) Condition (B) Iterator (C) Initializer (D) Break statement
Ans. : (C) Initializer
175. Which is second expression in for loop ?
(A) Initializer (B) Condition (C) Iterator (D) Break statement
Ans. : (B) Condition
176. Which is third expression in for loop ?
(A) Case statement (B) Initializer (C) Condition (D) Iterator
Ans. : (D) Iterator
177. Which of the following loop is exit-controlled loop ?
(A) Do...while (B) For (C) While (D) Continue

Ans.: (A) Do...while


178. In which loop statements of loops are executed at least once ?
(A) Do...while (B) For (C) While (D) Break
Ans.: (A) Do...while
179. Which statement is used to transfer the control outside switch or loop structure
?
(A) Continue (B) Exp1 (C) Exp3 (D) Break statement
Ans. : (D) Break statement
180. Which of the following statement skips all the following statements and control
is transferred at the first statement after the end of switch statement?
(A) Continue (B) Break (C) Condition (D) Iterator
Ans. : (B) Break
181. Which statement is used to exit the loop ?
(A) Iterator (B) Break (C) Continue (D) Condition
Ans. : (B) Break
182. Which statement is used to skip the following statements in a loop and continue
with the next iteration ?
(A) Iterator (B) Break (C) Switch (D) Initializer
Ans. : (C) Switch
183. What will be the output ?
for(i=5; i<=30; i=i+5)
{
If (i==20)
{
[Link](i);
continue;
}
}
(A) 5 10 15 25 30 (B) 5 10 15 20 25 30 (C) 5 6 7 ..... 30 (D) 5 10.... 95 100
Ans.: (A) 5 10 15 25 30
184. Which of the following include a class called Math ?
(A) Java class library (B) Main class (C) Loops (D) Branches
Ans.: (A) Java class library
185. How can we invoke function sqrt() of the class Math ?
(A) sqrt( ).Math (B) sqrt( )
(C) [Link]( ) (D) [Link]( )
Ans. : (C) [Link]( )
186. Which of the following is an object-oriented programming language developed
by Sun Microsystems?
(A) C language (B) BASIC (C) Java (D) FORTRAN
Ans. : (C) Java
187. Which company had developed the object-oriented programming language JAVA
?
(A) Microsoft (B) Sun Microsystems
(C) Netscape (D) Google
Ans. : (B) Sun Microsystems
188. A Java program is composed of.....
(A) Bytes (B) Functions (C) Classes (D) Procedures
Ans. : (C) Classes
189. What should be the extension of Java source file ?
(A) .class (B) .java (C) .javac (D) .program
Ans. : (B) .java
190. Which word in the first line of main() indicates that this routine can be called
from outside the program?
(A) Private (B) Public (C) Package (D) Void
Ans. : (B) Public
191. Which data type holds one of the two logical values true or false ?
(A) Byte (B) Short (C) Double (D) Boolean
Ans. : (D) Boolean
192. Which of the following is not proper to begin variable name ?
(A) An alphabet (B) Hash (#) (C) Underscore (_) (D) Dollar ($)
Ans. : (B) Hash (#)
193. Identify: "A name used for a constant value".
(A) Variable (B) Identifier (C) Literal (D) Keyword
Ans. : (C) Literal
194. Which Unicode sequence produces a trademark symbol TM
( ) ?
(A) \u1212 (B) \u2120 (C) \u2122 (D) \u1220
Ans. : (C) \u2122
195. Which delimiter is used for multiline comment?
(A) % (B) $ (C) // (D) /*....*/
Ans. : (D) /*....*/
196. Which are the special comments used for javadoc system ?
(A) Multi-line (B) Documentation (C) Single-line (D) API

Ans. : (B) Documentation


197. Identify: "The lower range data type is implicitly converted to higher data type to
have the same types of operands".
(A) Casting (B) Cast typing (C) Promotion (D) Range cast
Ans. : (C) Promotion
198. Which operator is used for Logical XOR operation ?
(A) && (B) || (C) ^ (D) !
Ans. : (C) ^
199. Which of the following determines the direction in which operations are
performed ?
(A) Priority (B) Associativity (C) Precedence (D) Scope
Ans. : (B) Associativity
200. What will be the type of variable, when we declare variables inside a block?
(A) Local (B) Loop (C) Branch (D) Operator
Ans.: (A) Local
----- -----

You might also like