Class-and-object

Question 1
Which of the following is associated with objects?
A
State
B
Behaviour
C
Identity
D
All of the above
       OOPS       Class-and-object       ISRO-2017 May
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.
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
A
only protected and public data of C and B
B
Only protected and public data of C
C
all data of C and private data of A and B
D
public and protected data of A and B and all data of C
       OOPS       Class-and-object       ISRO-2016
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
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
A
extern
B
static
C
volatile
D
const
       OOPS       Class-and-object       ISRO CS 2014
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.
Question 4
The memory occupied by an object type of data in VB is
A
1 byte
B
2 byte
C
4 byte
D
8 byte
       OOPS       Class-and-object       KVS 30-12-2018 Part B
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”;
   }
}
A
dogood : dogoodgood
B
dogood : gooddogood
C
dogood : dodogood
D
dogood : dogood
       OOPS       Class-and-object       UGC NET CS 2017 Nov- paper-3
Question 6
It is possible to define a class within a class termed as nested class. There are _____ types of nested classes.
A
2
B
3
C
4
D
5
       OOPS       Class-and-object       UGC NET CS 2016 July- paper-3
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.

Question 7
When one object reference variable is assigned to another object reference variable then
A
a copy of the object is created.
B
a copy of the reference is created.
C
a copy of the reference is not created.
D
it is illegal to assign one object reference variable to another object reference variable.
       OOPS       Class-and-object       UGC NET CS 2016 July- paper-3
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.

Question 8
Which of the following is a correct statement?
A
Composition is a strong type of association between two classes with full ownership.
B
Composition is a strong type of association between two classes with partial ownership.
C
Composition is a weak type of association between two classes with partial ownership.
D
Composition is a weak type of association between two classes with strong ownership.
       OOPS       Class-and-object       UGC NET CS 2016 Aug- paper-3
Question 8 Explanation: 
Question 9
Which of the following is not a correct statement?
A
Every class containing abstract method must be declared abstract.
B
Abstract class can directly be initiated with ‘new’ operator.
C
Abstract class can be initiated.
D
Abstract class does not contain any de nition of implementation.
       OOPS       Class-and-object       UGC NET CS 2016 Aug- paper-3
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.
Question 10
Converting a primitive type data into its corresponding wrapper class object instance is called
A
Boxing
B
Wrapping
C
Instantiation
D
Autoboxing
       OOPS       Class-and-object       UGC NET CS 2014 Dec - paper-3
There are 10 questions to complete.
PHP Code Snippets Powered By : XYZScripts.com
error: Content is protected !!