Wrapping States and Behaviour Is Called Encapsulation
Wrapping States and Behaviour Is Called Encapsulation
Wrapping States and Behaviour Is Called Encapsulation
A friend can be declared anywhere in the class declaration, and it cannot be affected by
access control keywords like private, public, or protected.
14) What is function overloading?
Function overloading is a regular function, but it can perform different tasks. It allows the
creation of several methods with the same name which differ from each other by the
type of input and output of the function.
15) What is operator overloading?
Operator overloading is a function where different operators are applied and depends on
the arguments. Operator,-,* can be used to pass through the function, and it has its own
precedence to execute
16) What is an abstract class?
An abstract class is a class which cannot be instantiated. Creation of an object is not
possible with an abstract class, but it can be inherited. An abstract class can contain
only an Abstract method. Java allows only abstract method in abstract class while other
languages allow non-abstract method as well.
17) What is a ternary operator?
The ternary operator is said to be an operator which takes three arguments. Arguments
and results are of different data types, and it depends on the function. The ternary
operator is also called a conditional operator.
18) What is the use of finalize method?
Finalize method helps to perform cleanup operations on the resources which are not
currently used. Finalize method is protected, and it is accessible only through this class
or by a derived class.
19) What are the different types of arguments?
A parameter is a variable used during the declaration of the function or subroutine, and
arguments are passed to the function body, and it should match with the parameter
defined. There are two types of Arguments.
Call by Value – Value passed will get modified only inside the function, and it
returns the same value whatever it is passed into the function.
Call by Reference – Value passed will get modified in both inside and outside the
functions and it returns the same or different value.
20) What is the super keyword?
The super keyword is used to invoke the overridden method, which overrides one of its
superclass methods. This keyword allows to access overridden methods and also to
access hidden members of the superclass.
Overriding is the same method names with the same arguments and return types
associated with the class and its child class.
26) What is the main difference between a class and an object?
An object is an instance of a class. Objects hold multiple information, but classes don’t
have any information. Definition of properties and functions can be done in class and
can be used by the object.
Doing Inheritance from that class.-Use Base Keyword from a derived class.
31) What is the difference between new and override?
The new modifier instructs the compiler to use the new implementation instead of the
base class function. Whereas, Override modifier helps to override the base class
function.
32) What are the various types of constructors?
There are three types of constructors:
– Parametric Constructor – With Parameters. Create a new instance of a class and also
passing arguments simultaneously.
The superclass is the parent class from which another class inherits.
45) What is static and dynamic Binding?
Binding is nothing but the association of a name with the class. Static Binding is a
binding in which name can be associated with the class during compilation time, and it is
also called as early Binding.
Dynamic Binding is a binding in which name can be associated with the class during
execution time, and it is also called as Late Binding.
46) How many instances can be created for an abstract class?
Zero instances will be created for an abstract class. In other words, you cannot create an
instance of an Abstract Class.
47) Which keyword can be used for overloading?
Operator keyword is used for overloading.
48) What is the default access specifier in a class definition?
Private access specifier is used in a class definition.
49) Which OOPS concept is used as a reuse mechanism?
Inheritance is the OOPS concept that can be used as a reuse mechanism.
50) Which OOPS concept exposes only the necessary information to the calling functions?
Encapsulation