OOPS Logical questions in c#,Interview Question


Introduction:- Today I am here with OOPS Logical questions in c#, which is mostly asked in every interview question. It will help you to crack C# OOPS interview.


OOPS Logical questions in c#,INTERVIEW QUESTION
OOPS Logical questions in c#



Q1:What is object?
An object is an instance of the class and also it is a reference pointer of a class. It allocated the memory to access the member of the class. If we want to access the class member we need to create an object of that particular class.

  Syntax for Object
  ClassName objectname=new ClassName();
  e.g Employee emp=new Employee();

In the above syntax object emp is a reference pointer for the Employee class.

Q.2: What is the naming convention?
The naming convention is a set of or a business logic rule by which we chose the character sequence to be used for function, class, textbox or any other entities in our source code so that later on we can easily  remember these sequence.

Q.3:Can we create a class name with the number?
No, We can't start a class name with the number only we can use the number in between i.e.

Public class Emp123
{

}

Q.4:Can we use a special character to create the class?
Yes only underScore (_)

Q.5:By default class follow which access modifier?
Internal

Q.6:Types of Access specifier/modifier?
There is 5 types of access modifier.
1.Public
2.Private
3.Protected
4.Internal
5.Protected Internal

Q.7: Can we create the class as private/protected/protected internal ?
No, By default class is Internal and you can mark class as Public only.

Q.8: By default class members are, means access modifier?
Private

Q.9: Difference b/w public, private and internal access modifier?
Difference Public/private/Internal/Protected/Protected internal
1.Public:                 Accessible in any project, but you have to add the reference
2.Private:                Member can be accessed in the same class only.
3.Internal:               Same Project.same Library, same assembly only.
4.Protected:            Only available in child class.
5.Procted Internal:   It behaves like protected + internal

Q.10: Difference between protected and protected internal?

Q.11:Can we mark the method as a sealed.
Yes.

Q.12:Is it possible to overload static constructor
No it's not.

Q.13:Why object of the abstract class can’t be instantiate
An abstract class has a protected constructor (by default) allowing derived types to initialize it.
An abstract type is defined largely as one that can't be created. You can create subtypes of it, but not of that type itself. The CLI will not let you do this.

Q.14:Does Enum Supports Inheritance
Enums do not support inheritance since they are value type and therefore are sealed. Enum is like a struct.it is having the nature of the sealed class. so it doesn't support inheritance.

Q.15:Where does the value of variables in structure get stored in memory?
Its store on Stack because Structure is value type.

Q.16:Can we use virtual keyword with functions in interface
This is no need to use virtual keyword with functions of the interface as it is by default made to override.  


Q.17:Is it possible to change access specifier of members of the interface.
No, We cannot make a change in the method of interface just why because the interface is publicly exposed for construction, so interface methods are public by default.
If you want to change access specifier of members may you have to go for an abstract class instead of the interface.


Thanks for reading the opps c# interview question and answer


Post a Comment

Post a Comment (0)

Previous Post Next Post