Class-and-object
Question 1 |
Which of the following is associated with objects?
State | |
Behaviour | |
Identity | |
All of the above |
Question 1 Explanation:
→ An object can be a variable, a data structure, a function, or a method, and as such, is a value in memory referenced by an identifier.
→ In the class based object-oriented programming paradigm, object refers to a particular instance of a class, where the object can be a combination of variables, functions, and data structures.
→ An object has state, exhibits some well defined behavior, and has a unique identity.
→ In the class based object-oriented programming paradigm, object refers to a particular instance of a class, where the object can be a combination of variables, functions, and data structures.
→ An object has state, exhibits some well defined behavior, and has a unique identity.
Question 2 |
If a class C is derived from class B, which is derived from class A, all through public inheritance, then a class C member function can access
only protected and public data of C and B | |
Only protected and public data of C | |
all data of C and private data of A and B | |
public and protected data of A and B and all data of C |
Question 2 Explanation:
→ It is nothing but multilevel inheritance.
→ If a class C is derived from class B, which is derived from class A, all through public inheritance, then a class C member function can access public and protected data of A and B and all data of C
→ If a class C is derived from class B, which is derived from class A, all through public inheritance, then a class C member function can access public and protected data of A and B and all data of C
Question 3 |
If only one memory location is to be reserved for a class variable, no matter how many objects are instantiated, then the variable should be declared as
extern | |
static | |
volatile | |
const |
Question 3 Explanation:
→ The static storage class instructs the compiler to keep a local variable in existence during the life-time of the program instead of creating and destroying it each time it comes into and goes out of scope. Therefore, making local variables static allows them to maintain their values between function calls.
→ The static modifier may also be applied to global variables. When this is done, it causes that variable's scope to be restricted to the file in which it is declared.
→ In C programming, when static is used on a global variable, it causes only one copy of that member to be shared by all the objects of its class.
→ The static modifier may also be applied to global variables. When this is done, it causes that variable's scope to be restricted to the file in which it is declared.
→ In C programming, when static is used on a global variable, it causes only one copy of that member to be shared by all the objects of its class.
Question 4 |
The memory occupied by an object type of data in VB is
1 byte | |
2 byte | |
4 byte | |
8 byte |
Question 4 Explanation:

Question 5 |
What is the output of the following JAVA program ?
Class Test {
public static void main(String[] args) {
Test obj = new Test();
obj.start();
}
void start() {
String stra = ”do”;
String strb = method(stra);
System.out.print(“: ”+stra + strb);
}
String method(String stra) {
stra = stra + ”good”;
System.out.print(stra);
return“ good”;
}
}
Class Test {
public static void main(String[] args) {
Test obj = new Test();
obj.start();
}
void start() {
String stra = ”do”;
String strb = method(stra);
System.out.print(“: ”+stra + strb);
}
String method(String stra) {
stra = stra + ”good”;
System.out.print(stra);
return“ good”;
}
}
dogood : dogoodgood | |
dogood : gooddogood | |
dogood : dodogood | |
dogood : dogood |
Question 6 |
It is possible to define a class within a class termed as nested class. There are _____ types of nested classes.
2 | |
3 | |
4 | |
5 |
Question 6 Explanation:
Nested classes are divided into two categories:
1. Static
2. Non static.
Nested classes that are declared static are simply called static nested classes.
Non static nested classes are called inner classes.
1. Static
2. Non static.
Nested classes that are declared static are simply called static nested classes.
Non static nested classes are called inner classes.
Question 7 |
When one object reference variable is assigned to another object reference variable then
a copy of the object is created. | |
a copy of the reference is created. | |
a copy of the reference is not created. | |
it is illegal to assign one object reference variable to another object reference variable. |
Question 7 Explanation:
• A reference variable is an alias, that is, another name for an already existing variable. Once a reference is initialized with a variable, either the variable name or the reference name may be used to refer to the variable.
• A reference variable must be initialized at the time of declaration.
• A reference variable must be initialized at the time of declaration.
Question 8 |
Which of the following is a correct statement?
Composition is a strong type of association between two classes with full ownership. | |
Composition is a strong type of association between two classes with partial ownership. | |
Composition is a weak type of association between two classes with partial ownership. | |
Composition is a weak type of association between two classes with strong ownership. |
Question 8 Explanation:

Question 9 |
Which of the following is not a correct statement?
Every class containing abstract method must be declared abstract. | |
Abstract class can directly be initiated with ‘new’ operator. | |
Abstract class can be initiated. | |
Abstract class does not contain any de nition of implementation. |
Question 9 Explanation:
A class which is declared as abstract is known as an abstract class. It can have abstract and non-abstract methods. It needs to be extended and its method implemented. It cannot be instantiated.
Rules:
1. An abstract class must be declared with an abstract keyword.
2. It can have abstract and non-abstract methods.
3. It cannot be instantiated.
4. It can have constructors and static methods also.
5. It can have final methods which will force the subclass not to change the body of the method.
Rules:
1. An abstract class must be declared with an abstract keyword.
2. It can have abstract and non-abstract methods.
3. It cannot be instantiated.
4. It can have constructors and static methods also.
5. It can have final methods which will force the subclass not to change the body of the method.
Question 10 |
Converting a primitive type data into its corresponding wrapper class object instance is called
Boxing | |
Wrapping | |
Instantiation | |
Autoboxing |
There are 10 questions to complete.