OOPS

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
Which of these is a super class of all errors and exceptions in the Java language?
A
Runtime Exceptions
B
Throwable
C
Catchable
D
None of the above
       OOPS       JAVA       ISRO-2017 May
Question 2 Explanation: 
The Throwable class is the superclass of all errors and exceptions in the Java language.
Question 3
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 3 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 4
Consider the following Java code fragment:
1   public class While
2   {
3          public void loop()
4          {
5                      int x = 0;
6                      while(1)
7                      {
8                                  System.out.println("x plus one is" +(x+1));
9                      }
10        }
11  }
A
There is syntax error in line no. 1
B
There is syntax errors in line nos. 1 & 6
C
There is syntax error in line no. 8
D
There is syntax error in line no. 6
       OOPS       JAVA       ISRO CS 2014
Question 4 Explanation: 
Java does not - unlike C - interpret 0 as false and 1 as true.
So we cannot use integers in the while() statement.
So line number 6 will give syntax error.
Question 5
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 5 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 6
Given a class named student, which of the following is a valid constructor declaration for the class?
A
Student student(){}
B
Private final student(){}
C
Student(student s){}
D
Void student(){}
       OOPS       Constructors       Nielit Scientist-B IT 4-12-2016
Question 6 Explanation: 
A constructor cannot specify any return type, not even void. A constructor cannot be final, static or abstract.
Question 7
Object oriented inheritance models:
A
"is a kind of" relationship
B
"has a" relationship
C
"want to be" relationship
D
"contains" of relationship
       OOPS       Properties       Nielit Scientist-B IT 4-12-2016
Question 7 Explanation: 
Generalization--> "is a kind of" relationship. It is used for object oriented inheritance models.
Aggregation-->"Has a" relationship
Question 8
Control Structures include
A
iteration
B
rendezvous statements
C
exception statements
D
all of these
       OOPS       Properties       Nielit Scientist-B CS 2016 march
Question 8 Explanation: 
● A control structure is a block of programming that analyzes variables and chooses a direction in which to go based on given parameters.
● The term flow control details the direction the program takes (which way program control "flows").
● Hence it is the basic decision-making process in computing; flow control determines how a computer will respond when given certain conditions and parameters.
Question 9
In object oriented design of software, objects have
A
attributes and name only
B
operations and name only
C
attributes name and operations
D
mutation and permutation property
       OOPS       Properties       Nielit Scientist-B CS 2016 march
Question 9 Explanation: 
● Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem.
● An object contains encapsulated data and procedures (operations) grouped together to represent an entity. The 'object interface' defines how the object can be interacted with.
Question 10
Give the output
#include
using namespace std;
class Base
{
Public:
int x,y;
Public:
Base(int i, int j)
{
x=i;y=j;
}
};
class Derived:public Base
{
public:
Derived(int i,int j):x(i),y(j){}
void print()
{
cout< };
int main(void)
{
Derived q(10,10);
q.print();
return 0;
}
A
1010
B
compile error
C
00
D
None of the option
       OOPS       Properties       Nielit Scientist-B IT 22-07-2017
Question 10 Explanation: 
We can’t directly assign the base class members by using​ ​ initializer list​ in the derived class
We should call the base class constructor in order to initialize base class members.
Question 11
Give the output
#include
using namespace
class Base1
{
public:
~Base1()
{
cout<<"Base1's destructor"< };
class Base2
{
public:
~Base1()
{
cout<<"Base2's destructor"< };
class Derived : public Base1,public Base2
{
public:
~Derived()
{
cout<<"Derived's destructor"< }
int main()
{
Derived d;
return 0;
}
A
Base1'1 destructor
Base2'2 destructor
Derived Destructor
B
Derived Destructor
Base2'2 destructor
Base1'1 destructor
C
Derived Destructor
D
Compiler Dependent
       OOPS       Destructors       Nielit Scientist-B IT 22-07-2017
Question 11 Explanation: 
● C++ constructor call order will be from top to down that is from base class to derived class and c++ destructor call order will be in reverse order.
● First child class and later parent class.
Question 12
Which of the following is/are true about packages in Java?
1) Every class is part of some package
2) All classes in a file are part of the same package
3)If no package is specified, the classes in the file go into a special unnamed package.
4) If no package is specified, a new package is created with folder name of class and the class is put in this package
A
Only 1,2 and 3
B
Only 1,2 and 4
C
Only 4
D
Only 1 and 3
       OOPS       Class       Nielit Scientist-B IT 22-07-2017
Question 12 Explanation: 
Option -4 false because new package is created by using syntax package package_name which is user defined .There is no relation with class name.
Question 13
Which of the following is false about abstract classes in java?
A
If we derive an abstract class and do not implement all the abstract methods, then the derived class should also be marked as abstract using 'abstract' keyword
B
Abstract classes can have constructors.
C
A class can be made abstract without any abstract method
D
A class can inherit from multiple abstract classes
       OOPS       Class       Nielit Scientist-B IT 22-07-2017
Question 13 Explanation: 
● An abstract class can have an abstract method without body and it can have methods with implementation also. ● Multiple inheritance is not possible with abstract classes.
Question 14
Which of the following is true about interfaces in java?
1. An interface can contain following type of members.
...public,static,final fields(i.e., constants)
...default and static methods with bodies
2. An instance of interface can be created.
3. A class can implement multiple interfaces
4. many classes can implement the same interface
A
1,3 and 4
B
1,2 and 4
C
2,3 and 4
D
1,2,3 and 4
       OOPS       Class       Nielit Scientist-B IT 22-07-2017
Question 14 Explanation: 
● The interface in java is a blueprint of a class. It has static constants and abstract methods.
● There can be only abstract methods in the Java interface, not method body.
● It cannot be instantiated just like the abstract class because there is no method definition available with the interface.
Question 15
If the objects focus on the problem domain, then we are concerned with
A
Object Oriented Analysis
B
Object Oriented Design
C
Object Oriented Analysis and design
D
None of the above
       OOPS       Properties       Nielit Scientific Assistance IT 15-10-2017
Question 15 Explanation: 
→ The purpose of any analysis activity in the software life cycle is to create a model of the system's functional requirements that is independent of implementation constraints.
→ The main difference between object-oriented analysis and other forms of analysis is that by the object-oriented approach we organize requirements around objects, which integrate both behaviors (processes) and states (data) modeled after real world objects that the system interacts with. In other or traditional analysis methodologies, the two aspects: processes and data are considered separately.
→ For example, data may be modeled by ER diagrams, and behaviors by flow charts or structure charts.
Question 16
Is null an object?
A
yes
B
No
C
Sometimes yes
D
None of these
       OOPS       Properties       Nielit Scientific Assistance IT 15-10-2017
Question 16 Explanation: 
If null were an Object, it would support the methods of java.lang.Object such as equals().
However, this is not the case - any method invocation on a null results in a NullPointerException.
There is also a special null type, the type of the expression null, which has no name. Because the null type has no name, it is impossible to declare a variable of the null type or to cast to the null type. The null reference is the only possible value of an expression of null type. The null reference can always be cast to any reference type. In practice, the programmer can ignore the null type and just pretend that null is merely a special literal that can be of any reference type
Question 17
Which of these events will be generated if we close an applet's window?
A
ActionEvent
B
ComponentEvent
C
AdjustmentEvent
D
WindowEvent
       OOPS       Properties       Nielit Scientific Assistance IT 15-10-2017
Question 17 Explanation: 
A low level event that indicates that a window has changed its status. This low-level event is generated by a Window object when it is opened, closed, activated, deactivated, iconified, or deiconified, or when focus is transferred into or out of the Window.
Question 18
Which two are valid constructors for Thread?
1. Thread(Runnable r, String name)
2. Thread()
3. Thread(int priority)
4.Thread(Runnable r, ThreadGroup g)
5.Thread(Runnable r, int priority)
A
1 and 3
B
2 and 4
C
1 and 2
D
2 and 5
       OOPS       Constructors       Nielit Scientific Assistance IT 15-10-2017
Question 18 Explanation: 
(1) and (2) are both valid constructors for Thread.
(3), (4), and (5) are not legal Thread constructors
Question 19
Which of the following object types are generally autonomous, meaning that they can exhibit some behavior without being operated upon by another object.
A
Passive
B
Active
C
Both A) and B)
D
None of the mentioned
       OOPS       Properties       Nielit Scientific Assistance IT 15-10-2017
Question 19 Explanation: 
● An active object is one that encompasses its own thread of control.
● Active objects are generally autonomous, meaning that they exhibit some behaviour without being operated upon by another object
● Passive objects can only undergo a state change when explicitly acted upon
Question 20
What is 'basis of Encapsulation'?
A
Object
B
Class
C
Method
D
All of the above
       OOPS       Properties       Nielit Scientific Assistance IT 15-10-2017
Question 20 Explanation: 
Encapsulation is the mechanism that binds together code and data it manipulates, and keeps both safe from outside interface and misuse. Class, which contains data members and methods is used to implement Encapsulation.
Question 21
In which case it is mandatory to provide a destructor in a class?
A
Almost in every class
B
Class for which two or more than two objects will be created
C
Class for which copy constructor
D
Class whose objects will be created dynamically
       OOPS       Destructors       KVS 22-12-2018 Part-B
Question 21 Explanation: 
→ Destructors are used to de-allocate the memory that has been allocated for the object by the constructor.
→ Unlike constructor a destructor neither takes any arguments nor does it returns value. And destructor can’t be overloaded.
Question 22
Runtime polymorphism is achieved by _____
A
Friend function
B
Virtual function
C
Operator overloading
D
Function overloading
       OOPS       Properties       KVS 22-12-2018 Part-B
Question 22 Explanation: 
→ In Run time Polymorphism, call is not resolved by the compiler.
→ Run time Polymorphism is achieved by virtual functions and pointers.
→ Compile time Polymorphism achieved by function overloading and operator overloading.
Question 23
Usually pure virtual function
A
Has complete function body
B
Will never be called
C
Will be called only to delete an object
D
Is defined only in derived class
       OOPS       Properties       KVS 22-12-2018 Part-B
Question 23 Explanation: 
→ A virtual function or virtual method is an inheritable and overridable function or method for which dynamic dispatch is facilitated.
→ A pure virtual function or pure virtual method is a virtual function that is required to be implemented by a derived class if the derived class is not abstract.
Question 24
Use of virtual function implies____
A
Overloading
B
Overriding
C
Static binding
D
Dynamic binding
       OOPS       Properties       KVS 22-12-2018 Part-B
Question 24 Explanation: 
→ A virtual function or virtual method is an inheritable and overridable function or method for which dynamic dispatch is facilitated.
→ Dynamic binding occurs when a pointer or reference is associated with a member function based on the dynamic type of the object.
→ The member function that is dynamically bound must override a virtual function declared in a direct or indirect base class.
Question 25
Additional information sent when an exception is thrown may be placed in___
A
Additional information sent when an exception is thrown may be placed in___
B
The function that caused the error
C
The catch block
D
An object of the exception class
       OOPS       Properties       KVS 22-12-2018 Part-B
Question 25 Explanation: 
→ A catch block is where you handle the exceptions, this block must follow the try block.
→ A single try block can have several catch blocks associated with it. You can catch different exceptions in different catch blocks.
→ When an exception occurs in try block, the corresponding catch block that handles that particular exception executes
Question 26
Which of the following is not correct in C++?
A
x-=2; is the same as x=x-2;
B
x*=2; is the same as x=x*2;
C
x%=2; is the same as x=x/2;
D
x/=2; is the same as x=x/2;
       OOPS       C++       KVS 22-12-2018 Part-B
Question 26 Explanation: 
→ x%=2; is not the same as x=x/2;
→ x%=2; is the same as x=x%2;
Question 27
Consider the following Java code segment:
Public class while /*line1*/
{
Public void loop()
{
int x=0;
while(1) /*line 6*/
{
system.out.println(“x plus one is”+(x+1));
}
}
}
Which of the following is true?
A
There is a syntax error in line -1
B
There are syntax errors in,line -1 and line -6
C
There is a syntax error in line -6
D
No syntax error
       OOPS       JAVA       KVS 22-12-2018 Part-B
Question 27 Explanation: 
We can’t used the keyword “while” as class name.So it will give syntax error.
Question 28
Parent class of all java classes is____
A
Java.lang.system
B
Java.lang.object
C
Java.lang.class
D
Java.lang,reflect.object
       OOPS       JAVA       KVS 22-12-2018 Part-B
Question 28 Explanation: 
public class Object:
Class Object is the root of the class hierarchy. Every class has Object as a superclass. All objects, including arrays, implement the methods of this class.
Question 29
Which of the following is not true in case of public inheritance in c++?
A
Each public member in the base class is public in the derived class
B
Each protected member in the base class is protected in the derived class
C
Each private member in the base class remains private in the base class
D
Each private member in the base class remains private in the derived class
       OOPS       Properties       KVS 22-12-2018 Part-B
Question 29 Explanation: 
→ Public Inheritance − When deriving a class from a public base class, public members of the base class become public members of the derived class and protected members of the base class become protected members of the derived class.
→ A base class's private members are never accessible directly from a derived class, but can be accessed through calls to the public and protected members of the base class. We can summarize the different access types according to - who can access them in the following way −

Question 30
How many characters does an escape sequence (\On, \Hn,\n,\f) in C++ consume?
A
1
B
3
C
2
D
None of these
       OOPS       Properties       KVS DEC-2013
Question 30 Explanation: 
→ An escape sequence is a sequence of characters that does not represent itself when used inside a character or string literal, but is translated into another character or a sequence of characters that may be difficult or impossible to represent directly.
→ All escape sequences consist of two or more characters, the first of which is the backslash, \ (called the "Escape character"); the remaining characters determine the interpretation of the escape sequence. For example, \n is an escape sequence that denotes a newline character.
→ If we treat it a character constant means one character
Note: An escape sequence is regarded as a single character and is therefore valid as a character constant.
Question 31
Which of the following is not true for overloaded function in C++?
A
Overloaded functions should have different arguments lists
B
Overloaded functions having the same argument lists should have a different return type.
C
Functions cannot be overloaded on the basis of one being static and the other non static
D
None of these
       OOPS       Properties       KVS DEC-2013
Question 31 Explanation: 
Two or more functions having same name but different argument(s) are known as overloaded functions. So option is not true.
Question 32
Which constructor will be called by the following lines of code?
(i) Student S1;
(ii) Student S2=S1;
A
First copy constructor, then default constructor
B
First default constructor, then copy constructor
C
Default constructor for both lines of code
D
Copy constructor for both lines of code
       OOPS       Constructors       KVS DEC-2013
Question 32 Explanation: 
→ Student S1:----whenever we create object to the class , automatically default constructor will be called.
→ Student S2=S1:------The copy constructor is a constructor which creates an object by initializing it with an object of the same class, which has been created previously.
Question 33
Which of the following statements is true?
A
The JAVA compile produces a code for JVM, which is executed by a JAVA interpreter
B
The JAVA compile produces code directly for JAVA interpreter
C
The JAVA compiler directly executes codes in JVM
D
The JAVA compile helps in directly executing a code on different operating
       OOPS       Properties       KVS DEC-2013
Question 33 Explanation: 
● JVM is a engine that provides runtime environment to drive the Java Code or applications. It converts Java bytecode into machines language.
● First, Java code is compiled into bytecode. This bytecode gets interpreted on different machines
Question 34
From the following java determine the attributes of the class students:
Class student
{
String name;
Int marks;
};
Public static void main()
{
Student S1=new student();
Student S2=new student();
}
A
Only name
B
Both name and marks
C
Only S1
D
Both S1 and S2
       OOPS       Properties       KVS DEC-2013
Question 34 Explanation: 
→ The attributes of student class are name and marks.
→ There are two objects created in the above program and both have same attributes.
Question 35
The figure below depicts the hierarchy_____class
A
Heap
B
Wrapper
C
Inheritance
D
Abstract
       OOPS       Class       KVS DEC-2013
Question 35 Explanation: 
All the wrapper classes (Integer, Long, Byte, Double, Float, Short) are subclasses of the abstract class Number.
Question 36
​ To override a method in java, we need to define a method in a subclass with the
A
Same name, same number of arguments having the same data types as a method in the superclass
B
Different name, same number of arguments having the same data types as a method in the superclass
C
Same name but different number of arguments as a method in the superclass
D
Same name, same number of arguments but different data types as a method in the superclass
       OOPS       Class       KVS DEC-2013
Question 36 Explanation: 
●The argument list should be exactly the same as that of the overridden method.
● The return type should be the same or a subtype of the return type declared in the original overridden method in the superclass.
Question 37
In object oriented programming, by wrapping up characteristics and behaviour into one unit, we achieve
A
Data Abstraction
B
Data Encapsulation
C
Data Hiding
D
All of these
       OOPS       Properties       KVS DEC-2013
Question 37 Explanation: 
●Data hiding is a software development technique specifically used in object-oriented programming (OOP) to hide internal object details (data members). Data hiding ensures exclusive data access to class members and protects object integrity by preventing unintended or intended changes.
● Data abstraction refers to providing only essential information to the outside world and hiding their background details, i.e., to represent the needed information in program without presenting the details.
● Encapsulation is a process of combining data members and functions in a single unit called class. This is to prevent the access to the data directly, the access to them is provided through the functions of the class.
Question 38
The major goal of object oriented programming is
A
top down program development
B
Speed
C
User interface
D
Reuse
       OOPS       Properties       KVS DEC-2017
Question 38 Explanation: 
Languages that support object oriented programming typically use inheritance for code reuse and extensibility in the form of either classes or prototypes. Those that use classes support two main concepts:
1. Classes – the definitions for the data format and available procedures for a given type or class of object; may also contain data and procedures (known as class methods) themselves, i.e. classes contain the data members and member functions
2. Objects – instances of classes
Question 39
Assume the C++ definitions: Class circle: public point which of the following is false?
A
'point' is the base class and 'circle' is the derived class
B
The colon(:) in the header of class definition indicates inheritance
C
The keyword 'public' indicates type of inheritance
D
All the public and protected members of class 'circle' are inherited as public and protected members respectively into class point.
       OOPS       Class       KVS DEC-2017
Question 39 Explanation: 
True: point' is the base class and 'circle' is the derived class
True: The colon(:) in the header of class definition indicates inheritance
True: The keyword 'public' indicates type of inheritance
False: All the public and protected members of class 'circle' are inherited as public and protected members respectively into class point.
Question 40
Which of the following java statement declare and allocate a 2-dimensional array integers with four rows and five columns?
A
int array[ ] [ ]=new int [5][4];
B
int array [4][5];
C
int array[5][4];
D
int array[ ] [ ]=new int[4][5];
       OOPS       JAVA       KVS DEC-2017
Question 40 Explanation: 
→ In question they are clearly mentioned that 4 rows and 5 columns.
→ ​ Syntax int array[ ] [ ]=new int[row size][column size];
(or)
int[ ] [ ] array=new int[row size][column size];
So, Option D is correct answer.
Question 41
What is garbage collection in the context of java?
A
The java virtual machine(JVM) checks the output of any java program and deletes anything that does not make sense at all
B
The operating system periodically deletes all of the java files available on the system
C
Any java packages imported in a program and not being used, is automatically deleted
D
When all references to an object are going, then the memory used by the object is automatically reclaimed
       OOPS       JAVA       KVS DEC-2017
Question 41 Explanation: 
Garbage collection is happened when all references to an object are going, then the memory used by the object is automatically reclaimed
Question 42
What correction is required for following Java code snippet to compile?
int[]x=new int[10];
for(int P=0;P<=X.length();P++)
X[P]=5;
A
X[P]=5 should be X(p)=5
B
P<=X.length() should be P
C
X.length() should be X.length
D
P++ should be P+1
       OOPS       JAVA       KVS DEC-2017
Question 42 Explanation: 
Integer data type we are using X.length and character data type we are using function X.length().
→ array.length : length is a final variable applicable for arrays. With the help of length variable, we can obtain the size of the array.
→ string.length() : length() method is a final variable which is applicable for string objects. length() method returns the number of characters presents in the string.
Question 43
Which of the following most accurately describes "multiple inheritance"?
A
When a child class has both an "is a" and "has a" relationship with its parent class
B
When two classes inherit from each other
C
When a base class has two or more derived classes
D
When a child class has two or more parent class
       OOPS       Properties       KVS DEC-2017
Question 43 Explanation: 
→ Multiple inheritance is a feature of some object-oriented computer programming languages in which an object or class can inherit characteristics and features from more than one parent object or parent class. It is distinct from single inheritance, where an object or class may only inherit from one particular object or class.
Question 44
java is a___language. This means that you must be explicit about what type of data you are working with
A
Weakly typed
B
strongly typed
C
Dynamically typed
D
Loosely typed
       OOPS       JAVA       KVS DEC-2017
Question 44 Explanation: 
→ Java is a strongly typed programming language because every variable must be declared with a data type. A variable cannot start off life without knowing the range of values it can hold, and once it is declared, the data type of the variable cannot change.
Question 45
Consider the following code segment in JAVA
switch(x)
{
default;
system.out.println(“Hello”);
}
Which of the following data types are acceptable for x?
A
Byte and char
B
Long and char
C
Char and float
D
Byte and float
       OOPS       JAVA       KVS 30-12-2018 Part B
Question 45 Explanation: 
The possible values are either integer constant or character constant.No other data type values are allowed.
Question 46
Which of the following are valid calls to math.max in java?
  1. Math.max(1,4)
  2. Math.max(2.3,5)
  3. Math.max(1,3,5,7)
  4. Math.max(-1.5,-2.8f)
A
A,b and d
B
B,c and d
C
A,b and c
D
C and d
       OOPS       JAVA       KVS 30-12-2018 Part B
Question 46 Explanation: 
→The java.lang.Math.max(int a, int b) returns the greater of two int values.
→We can find the greater of any two data types variables.
→Option C consists of four variables , So it is invalid.
Question 47
Which of the following is NOT true in C++?
A
Before a variable can be used, it must be declared
B
Variable are allocated values through the use of assignment statements
C
When a variable is declared, C++ allocates storage for the variable and puts an unknown value inside it.
D
We can use a variable even if it is not declared.
       OOPS       C++       KVS 30-12-2018 Part B
Question 47 Explanation: 
In the c++ (or) C programming language , in order to use the variables in the program we must declare the variables before using.
Question 48
Which of the following is NOT true in case of protected Inheritance in C++?
A
Each public member in the base class is protected in the derived class
B
Each protected member in the base class is protected in the derived class
C
Each private member in the base class is private in the derived class
D
Each private member in the base class is visible in the derived class
       OOPS       Properties       KVS 30-12-2018 Part B
Question 48 Explanation: 
The following table shows the access to members permitted by each modifier.
Question 49
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
Protected and public data only in C and B
B
Protected and public data only in C
C
Private data in A and B
D
Protected data in A and B
       OOPS       Class       KVS 30-12-2018 Part B
Question 49 Explanation: 
The following table shows the access to members permitted by each modifier.
Question 50
Mechanism of deriving a class from another derived class is known as
A
Polymorphism
B
Single inheritance
C
Multilevel inheritance
D
Message passing
       OOPS       Properties       KVS 30-12-2018 Part B
Question 50 Explanation: 
When a class is derived from a class which is also derived from another class, i.e. a class having more than one parent classes, such inheritance is called Multilevel Inheritance.
Question 51
Members of  class by default are
A
Public
B
Private
C
Protected
D
Mandatory to specify
       OOPS       Class       KVS 30-12-2018 Part B
Question 51 Explanation: 
→A class in C++ is a user defined type or data structure declared with keyword class that has data and functions (also called methods) as its members whose access is governed by the three access specifiers private, protected or public (by default access to members of a class is private).
→The private members are not accessible outside the class; they can be accessed only through methods of the class. The public members form an interface to the class and are accessible outside the class.
Question 52
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 52 Explanation: 

Question 53
If a function is friend of a class, which one of the following is wrong?
A
A function can only be declared a friend by a class itself.
B
Friend functions are not members of a class, they are associated with it.
C
Friend functions are members of a class.
D
It can have access to all members of the class, even private ones.
       OOPS       Functions       UGC NET CS 2016 Aug- paper-2
Question 53 Explanation: 
→ A friend function of a class is defined outside that class' scope but it has the right to access all private and protected members of the class. Even though the prototypes for friend functions appear in the class definition, friends are not member functions.
TRUE: function can only be declared a friend by a class itself.
TRUE: Friend functions are not members of a class, they are associated with it.
FALSE:Friend functions are members of a class.
TRUE: It can have access to all members of the class, even private ones.
Question 54
Which one of the following is correct, when a class grants friend status to another class?
A
The member functions of the class generating friendship can access the members of the friend class.
B
All member functions of the class granted friendship have unrestricted access to the members of the class granting the friendship.
C
Class friendship is reciprocal to each other.
D
There is no such concept.
       Oops       Friend-class       UGC NET CS 2016 July- paper-2
Question 54 Explanation: 
→ When a class grants friend status to another class all member functions of the class granted friendship have unrestricted access to the members of the class granting the friendship.
→ Although the entire second class must be a friend to the first class, you can select which functions in the first class will be friends of the second class.
Question 55
When a method in a subclass has the same name and type signatures as a method in the super class, then the method in the subclass _____ the method in the super class.
A
Overloads
B
Friendships
C
Inherits
D
Overrides
       OOPS       Functions       UGC NET CS 2016 July- paper-2
Question 55 Explanation: 
→ When a method in a subclass has the same name and type signatures as a method in the superclass, then the method in the subclass overrides the method in the superclass.
Question 56
Consider the following two statements:
(a) A publicly derived class is a subtype of its base class.
(b) Inheritance provides for code reuse.
A
Both the statements (a) and (b) are correct.
B
Neither of the statements (a) and (b) are correct
C
Statement (a) is correct and (b) is incorrect
D
Statement (a) is incorrect and (b) is correct.
       OOPS       Inheritance       UGC NET CS 2015 Dec- paper-2
Question 56 Explanation: 
→ A publicly derived class is a subtype of its base class.
→ Inheritance is defined as deriving new classes (sub classes) from existing ones (super class or base class) and forming them into a hierarchy of classes.
→ Inheritance allows programmers to create classes that are built upon existing classes, to specify a new implementation while maintaining the same behaviors (realizing an interface), to reuse code and to independently extend original software via public classes and interfaces.
Question 57
In C++, which system - provided function is called when no handler is provided to deal with an exception?
A
terminate( )
B
unexpected( )
C
abort( )
D
kill( )
       OOPS       UGC NET CS 2015 Dec- paper-2
Question 57 Explanation: 
In some cases, the exception handling mechanism fails and a call to void terminate() is made. This terminate() call occurs in any of the following situations:
The exception handling mechanism cannot find a handler for a thrown exception. The following cases are more specific:
1. During stack unwinding, a destructor throws an exception and that exception is not handled.
2. The expression that is thrown also throws an exception, and that exception is not handled.
3. The constructor or destructor of a nonlocal static object throws an exception, and the exception is not handled.
4. A function registered with atexit() throws an exception, and the exception is not handled. The following demonstrates this:
A throw expression without an operand tries to rethrow an exception, and no exception is presently being handled.
Question 58
Which of the following differentiates between overloaded functions and overridden functions ?
A
Overloading is a dynamic or runtime binding and overridden is a static or compile time binding.
B
Overloading is a static or compile time binding and overriding is dynamic or runtime binding.
C
Redefining a function in a friend class is called overloading, while redefining a function in a derived class is called as overridden function.
D
Redefining a function in a derived class is called function overloading, while redefining a function in a friend class is called function overriding.
       OOPS       OOPS-concepts       UGC NET CS 2014 Dec-Paper-2
Question 58 Explanation: 
Question 59
What is the output of the following JAVA program ?
class simple
{
public static void main(String[ ] args)
{
simple obj = new simple( );
obj.start( );
}
void start( )
{
long [ ] P= {3, 4, 5};
long [ ] Q= method (P);
System.out.print (P[0] + P[1] + P[2]+”:”);
System.out.print (Q[0] + Q[1] + Q[2]);
}
long [ ] method (long [ ] R)
{
R [1]=7; return R;
}
} //end of class
A
12 : 15
B
15 : 12
C
12 : 12
D
15 : 15
       OOPS       JAVA       UGC NET CS 2018 JUNE Paper-2
Question 59 Explanation: 
First we will create the object of simple class.
By using object , we call the function start().
In the start() function definition, first statement is integer array with three elements.
long [ ] Q= method (P); Again function method(p) will be called.
In the definition of method function, we are changing the second element of array to value 7 and returning updated array to array Q.
We are passing address of P as argument to method so Modifications happened in the method automatically reflects to array P.
Both array P and Q consists of values {3,7,5}
The sum of the three values are 15
Question 60
​In Java, which of the following statements is/are True ?
S1 : The ‘final’ keyword applied to a class definition prevents the class from being extended through derivation.
S2 : A class can only inherit one class but can implement multiple interfaces.
S3 : Java permits a class to replace the implementation of a method that it has inherited. It is called method overloading.
A
S1 and S2 only
B
S1 and S3 only
C
S2 and S3 only
D
All of S1, S2 and S3
       OOPS       JAVA       UGC NET CS 2018 JUNE Paper-2
Question 60 Explanation: 
● If a class has multiple methods having same name but different in parameters, it is known as Method Overloading.Method Overloading is a feature that allows a class to have more than one method having the same name, if their argument lists are different.So the option-3 is False.
● The final keyword in java is used to restrict the user. The java final keyword can be used in many context. Final can be: variable, method and class.
● A Java class can only extend one parent class. Multiple inheritance (extends) is not allowed. Interfaces are not classes, however, and a class can implement more than one interface.
Question 61
Which of the following statements is/are TRUE regarding JAVA ? (a) Constants that cannot be changed are declared using the ‘static’ keyword. (b) A class can only inherit one class but can implement multiple interfaces.
A
Only (a) is TRUE.
B
Only (b) is TRUE.
C
Both (a) and (b) are TRUE.
D
Neither (a) nor (b) are TRUE.
       OOPS       JAVA       UGC NET CS 2017 Nov- paper-3
Question 61 Explanation: 
FALSE: Constants that cannot be changed are declared using the ‘static’ keyword.
TRUE: A class can only inherit one class but can implement multiple interfaces.
Question 62
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
There are 62 questions to complete.
PHP Code Snippets Powered By : XYZScripts.com