You are on page 1of 7

OOPS(Pdf no 5)

1.What is full form of oops?


Ans-Object oriented programming language.

2.A class composed of which things?


Ans-A class is composed of field data (member variables) and methods
(member functions).

3.Who is consider as the instance of the class?


Ans-An object is consider as the instance of the class.

4. When a class is consider as logical abstraction?


Ans-Only when the object of the class is created .

5.Data members also called?


Ans- Data members also called fields.

6.What is the role of access specifier and give some examples?


Ans-It provides access to class.Examples -public,private,protected etc.

7.What is the role of constructer?


Ans-It initialize the object.
8.What shoud be the name of a constructor?
Ans- constructor name should be same as the class name.
9.How many types of constructors are there and what are they?
Ans-2 types 1.Default 2.Static

10.What is default constructor give an example?


Ans- Default Constructor will get automatically created and invoked, if
constructor is not Specified in the classand assign the instance variables
with their default values.

11.What is static constructor ?


Ans- This is similar to static method. It must be parameter less and
must not have an access modifier (private or public).

12.what is a method?
Ans- A method is a member that implements a computation or action
that can be performed by an object or class.
13.How many parameters are there what are they?
Ans- There are four kinds of parameters:
• out
• ref
• params
• value
14.What is a Value parameter and what is the use of it?
Ans- If a parameter does not have any modifier, it is the value
parameter by default. When you use the value parameter, the actual
value is passed to the function.

15.What is method overloading?


Ans- Two or more methods within the same class can share the same
name, if their parameter declarations are different.
In such cases, the methods are said to be overloaded, and the process
is referred to as method overloading.

16.Polymorphism can be achieved by- method overloading

17.Can constructors be overloaded like methods?


Ans-yes

18.To access static members do we need to create object?


Ans-No. we can call static members by dot operator.

19.What is internal and protected internal class?


Internal: Access is limited to the current assembly.
Protected internal: Access is limited to the current assembly or
types derived from the containing class.

20.Geter and setter are –Methods

21.what are indexers?


 Indexers are ‘smart arrays’.
 Indexers permit instances of a class or struct to be indexed in the
same way as arrays.

22.what is inheritance?
Ans-Inheritance is a form of software reusability in which classes are
created by reusing the data and behaviors of an existing class with new
capabilities.

23.Give an example of ‘is a’ relationship?


Ans –Inheritance

24.Can base class and derive class have same constructors?


Ans-Yes

25.What is a virtual method?


Ans- A virtual method is a method that is declared as virtual in a base
class and redefined in one or more derived classes.

26.when we use override modifier?


Ans-When a virtual method is redefined by a derived class, the override
modifier is used.

27.What is An Abstarct class?


Ans-An abstract class is the one that cannot be instantiated.
It is intended to be used as a base class.

28.What is a sealed class?


Ans-To prevent inheritance, a sealed modifier is used to define a class.
A sealed class is the one that cannot be used as a base class. Sealed
classes can’t be abstract.

30.What are interfaces?


Ans-An interface defines a contract.
Interface is a purely abstract class; it has only signatures, no
Implementation.
31.Can interface members be static?
Ans-No

32.Can a single class implement multiple interface?


Ans-yes

33.What is the difference between abstract class and interface?


Ans-
Abstract classes can be used to define public, private and
protected state data, as well as any number of concrete methods
that can be accessed by the subclasses
Interfaces never define data types, and never provide a default
implementation of the methods
34.Can we create Object of static class?
Ans-No

35.Difference between structure and Class?


Ans-Structure is value type and don’t have destructor.
Class is a reference type and have destructor.

36.What is the use of Extension Methods?


Ans- Extension methods cannot be used to override existing methods.
An extension method with the same name and signature as an
instance method will not be called.
37.What is object initialize?
An object initializer is used to assign values to an object fields or
properties when the object is created.
38.What is projection?
Ans-Anonymous types are also called projection.

39.When we should not use Anonymous Types?


Ans- There is a need to define a method
There is a need to define another variable.
There is a need to share data across methods

40.what is namespaces?
Ans- A namespace defines a declarative region that provides a way to
keep one set of names separate from another.
Thus, names declared in one namespace will not conflict with the
same names declared in another.

41.what is the use of partial types?


Ans- Partial types allow classes, structs, and interfaces to be broken
into multiple pieces stored in different source files for easier
development and maintenance.
42.What should be the name of constructor?
Ans-Same as class name.
43.Does constructor has any explicit return type?
Ans-no
44.what is the use of internal access specifier?
Ans-it give the access to current assembly.
45.what is the use of protected internals access specifier?
Ans-Access is limited to the current assembly or types derived from the
containing class.
46. A property without a set accessor is considered as -read-only

47.A property without a get accessor is considered as-write-only

48. To create a ‘read only’ auto-implemented property, USE A PRIVATE


SET ACCESSOR.

49.What is Enumeration?
Ans-An enumeration is a set of named integer constants.
An enumerated type is declared using the enum keyword

You might also like