OOPS

Question 1

A software engineer is required to implement two sets of algorithms for a single set of matrix operations in an object oriented programming language; the two sets of algo­rithms are to provide precisions of 10-3 and 10-6, respectively. She decides to implement two classes, Low Precision Matrix and High Precision Matrix, providing precisions 10-3 and 10-6 respectively. Which one of the following is the best alternative for the imple­mentation?

    (S1) The two classes should be kept independent.
    (S2) Low Precision Matrix should be derived from High Precision Matrix.
    (S3) High Precision Matrix should be derived from Low Precision Matrix.
    (S4) One class should be derived from the other; the hierarchy is immaterial.
A
S1
B
S2
C
S3
D
S4
       OOPS       Matrix       GATE 2008-IT
Question 1 Explanation: 
Note: Out of syllabus.
Question 2
Which of the following operator(s) cannot be overloaded?
A
. (Member Access or Dot operator)
B
?: (Ternary or Conditional Operator )
C
:: (Scope Resolution Operator)
D
All of the above
       OOPS       Properties       ISRO-2017 May       Video-Explanation
Question 2 Explanation: 
. (Member Access or Dot operator), ?: (Ternary or Conditional Operator ) and :: (Scope Resolution Operator) are ternary operators. It can’t be overloaded.
Question 3
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       Video-Explanation
Question 3 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 4
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       Video-Explanation
Question 4 Explanation: 
The Throwable class is the superclass of all errors and exceptions in the Java language.
Question 5
Type 4 JDBC driver is a driver
A
which is written in C++
B
which requires an intermediate layer
C
which communicates through Java sockets
D
which translates JDBC function calls into API not native to DBMS
       OOPS       JAVA       ISRO-2017 December       Video-Explanation
Question 5 Explanation: 
The JDBC type 4 driver, also known as the Direct to Database Pure Java Driver, is a database driver implementation that converts JDBC calls directly into a vendor-specific database protocol.
Written completely in Java, type 4 drivers are thus platform independent. They install inside the Java Virtual Machine of the client. This provides better performance than the type 1 and type 2 drivers as it does not have the overhead of conversion of calls into ODBC or database API calls. Unlike the type 3 drivers, it does not need associated software to work.
As the database protocol is vendor specific, the JDBC client requires separate drivers, usually vendor supplied, to connect to different types of databases.

Advantages Completely implemented in Java to achieve platform independence.
These drivers don’t translate the requests into an intermediary format (such as ODBC).
The client application connects directly to the database server. No translation or middleware layers are used, improving performance.
The JVM can manage all aspects of the application-to-database connection; this can facilitate debugging.

Disadvantages Drivers are database specific, as different database vendors use widely different (and usually proprietary) network protocols.

Type-1 driver (or) JDBC-ODBC bridge driver
Type-2 driver (or) Native-API driver
Type-3 driver (or) Network Protocol driver
Type-4 driver (or) Thin driver
Question 6
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       Video-Explanation
Question 6 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 7
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 7 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 8
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       Video-Explanation
Question 8 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 9

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 9 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 10

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.
Code :
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 10 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 11

Which of the following statements is/are True ?

P : C programming language has a weak type system with static types. Q : Java programming language has a strong type system with static types. Code :
A
P only
B
Q only
C
Both P and Q
D
Neither P nor Q
       OOPS       JAVA       UGC-NET CS 2018 JUNE Paper-2
Question 11 Explanation: 
→ A strongly typed language has stricter typing rules at compile time, which implies that errors and exceptions are more likely to happen during compilation. Most of these rules affect variable assignment, return values and function calling.
→ A weakly typed language has looser typing rules and may produce unpredictable results or may perform implicit type conversion at runtime.
→ Java, C#, Ada and Pascal are sometimes said to be more strongly typed than C, a claim that is probably based on the fact that C supports more kinds of implicit conversions, and C also allows pointer values to be explicitly cast while Java and Pascal do not.
→ Java itself may be considered more strongly typed than Pascal as manners of evading the static type system in Java are controlled by the Java virtual machine’s type system.
→ C# and VB.NET are similar to Java in that respect, though they allow disabling of dynamic type checking by explicitly putting code segments in an “unsafe context”.
→ Pascal’s type system has been described as “too strong”, because the size of an array or string is part of its type, making some programming tasks very difficult.
Question 12
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 12 Explanation: 
A constructor cannot specify any return type, not even void. A constructor cannot be final, static or abstract.
Question 13
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 13 Explanation: 
Generalization–> “is a kind of” relationship. It is used for object oriented inheritance models.
Aggregation–>”Has a” relationship
Question 14
Control Structures include
A
iteration
B
rendezvous statements
C
exception statements
D
all of these
       OOPS       Properties       Nielit Scientist-B CS 2016 march
Question 14 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 15
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 15 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 16
Which one of the following are essential features of object oriented language?
  1. Abstraction and encapsulation
  2. Strictly-typed
  3. Type-safe property coupled with sub-type rule
  4. Polymorphism in the presence of inheritance
A
A and B only
B
A, D and B only
C
A and D only
D
A, C and D only
       OOPS       Properties       ISRO DEC 2017 22- Soon       Video-Explanation
Question 16 Explanation: 

Question 17
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 17 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 18
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 18 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 19
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 19 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 20
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 20 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 21
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 21 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 22
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 22 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 23
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 23 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 24
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 24 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 25
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 25 Explanation: 
(1) and (2) are both valid constructors for Thread.
(3), (4), and (5) are not legal Thread constructors
Question 26
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 26 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 27
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 27 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 28
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 28 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 29
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 29 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 30
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 30 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 31
Use of virtual function implies____
A
Overloading
B
Overriding
C
Static binding
D
Dynamic binding
       OOPS       Properties       KVS 22-12-2018 Part-B
Question 31 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 32
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 32 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 33
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 33 Explanation: 
→ x%=2; is not the same as x=x/2;
→ x%=2; is the same as x=x%2;
Question 34
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 34 Explanation: 
We can’t used the keyword “while” as class name.So it will give syntax error.
Question 35
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 35 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 36
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 36 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 37
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 37 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 38
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 38 Explanation: 
Two or more functions having same name but different argument(s) are known as overloaded functions. So option is not true.
Question 39
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 39 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 40
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 40 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 41
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 41 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 42
The figure below depicts the hierarchy_____class
A
Heap
B
Wrapper
C
Inheritance
D
Abstract
       OOPS       Class       KVS DEC-2013
Question 42 Explanation: 
All the wrapper classes (Integer, Long, Byte, Double, Float, Short) are subclasses of the abstract class Number.
Question 43
​ 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 43 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 44
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 44 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 45
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 45 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 46
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 46 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 47
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 47 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 48
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 48 Explanation: 
Garbage collection is happened when all references to an object are going, then the memory used by the object is automatically reclaimed
Question 49
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 49 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 50
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 50 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.
There are 50 questions to complete.

Access subject wise (1000+) question and answers by becoming as a solutions adda PRO SUBSCRIBER with Ad-Free content

Register Now