Showing posts with label Interview Questions. Show all posts
Showing posts with label Interview Questions. Show all posts

Saturday

.Net OOPS: OOPS interview questions

Introduction (OOPS)

OOPS Programming allows us to develop smaller to smaller logical modules, later we can integrate into one form of software. OOPS includes classes under that methods, entities, events, properties, modules etc. By creating objects can access data in OOPS programming. .Net framework supports only OOPS languages such as vb.net, c#, asp.net, C++ etc. In my earlier example, I have covered almost all MVC ASP.Net Interview Questions And Answers.

1) What is class in .Net OOPS Programming?

Access modifiers allows us to access its class members in different types like Public, Private, Protected, Internal, Protected internal, Static.
Class Inheritance allow us to do to access its base class information and behaviour. Colon image permits us to inherit its base class from derive class.
public class Furniture
    {
        //Fields, properties, methods, members, events, constructors, destructors etc.
    }

2) What is Class and Class Inheritance in OOPS Programming?

public class Furniture
    {
        //Fields, properties, methods, members, events, constructors, destructors etc.
    }
 Public class Sandal:Furniture
    {
        //Fields, properties, methods, members, events, constructors, destructors etc.
    }

3) What are objects in OOPS?

Objects are like variable those who enable to encapsulate data and behaviour
Furniture _obj = new Furniture();

4) What are the basic concepts of OOPS ?

Main top four main features of OOPS are as follows:
I) Abstraction:- In .net framework, abstraction enable to use multiple inheritance, with the access of abstraction can hide important data and show only important data to show user.
II) Polymorphism: It capable to use one form into multiple forms.
II) Encapsulation: We can say encapsulation is subset of abstraction. We can restrict user to show data with the use of encapsulation.
IV) Inheritance: While we are using inheritance there are two main parts one is derived class and other one is base class. Inheritance provides to capable our application to reuse our code and reduce code size.
oops main components
OOPS main components

5). Which of the following type of class allows only one object of it to be created?

  • Virtual class
  • Abstract class
  • Singleton class
  • Friend class

6). Which of the following statements is correct?

  • Base class pointer cannot point to derived class.
  • Derived class pointer cannot point to base class.
  • Pointer to derived class cannot be created.
  • Pointer to base class cannot be created.

7). Which of the following is not the member of class?

  • Static function
  • Friend function
  • Const function
  • Virtual function

8). Which of the following concepts means determining at run time what method to invoke?

  • Data hiding
  • Dynamic Typing
  • Dynamic binding
  • Dynamic loading

9). Which of the class’s instances themselves are classes?

  • Subclass
  • Abstarct Class
  • Metaclass
  • Object Class

10). Which of the following concept of oops allows compiler to insert arguments in a function call if it is not specified?

  • Call by value
  • Call by reference
  • Default arguments
  • Call by pointer

11). Which of the following cannot be friend?

  • Function
  • Class
  • Object
  • Operator function

12). Which of the following concepts of OOPS means exposing only necessary information to client?

  • Encapsulation
  • Abstraction
  • Data hiding
  • Data binding

13). Why reference is not same as a pointer?

  • A reference can never be null.
  • A reference once established cannot be changed.
  • Reference doesn't need an explicit dereferencing mechanism.
  • All of the above.

14) Initialise var to null in C# ?

  • var _myVal = (dynamic)null; 
  • var _myVal = (int32)null; 
  • var _myVal = (int)null; 
  • var _myVal = (string)null; 
  • None;

15) What is Mutable string in .Net framework OOPS? 

  • A mutable string state can't be change 
  • A mutable string state can be change 
  • None 

16) What is Immutable string in .Net framework OOPS?

  • A Immutable string state can't be change 
  • A Immutable string state can be change
  • None
Read More: Difference between mutable and immutable string in .Net framework

17) What is boxing ?

  • Object to value 
  • Value to object 
  • Both A and B 
  • None
int a = 123;
object o = a;  //boxing

18) What is unboxing ? 

  • Object to value 
  • Value to object 
  • Both A and B 
  • None
o = 123;
a = (int)o;  // unboxing
Read More: What is Boxing and Unboxing in .Net Framework

19) Which modifier is used to class as a sealed class? 

  • Protected 
  • Private 
  • Sealed 
  • None 

20) A sealed class cannot be used as a base class? 

  • Yes 
  • No 
  • None 

21) Can be use sealed class as an abstract class? 

  • Yes 
  • No 
  • None 

22) Can be use sealed class for inheritance?

  • No 
  • Yes 
  • None 

23) Can be structs considered like sealed class? 

  • No 
  • Yes 
  • None
public sealed class Csharp
{
    // Class members here.
}

24) Can we instantiate Interface class ? 

  • Interface can be instantiated 
  • Interface cannot be instantiated 
  • Both A and B 
  • None 

25) Does Interface class require inheriting ?

  • No 
  • Yes 
  • None 

26) Which keyword is used to class as a sealed class?

  • Protected 
  • Private 
  • Sealed 
  • None 

 27) Does Interface class support inheriting?

  • Yes 
  • No 
  • None 

28) Can Interfaces contain only the declaration of the members?

  • Yes 
  • No 
  • None 

29) Which keyword is required to make Interface class?

  • Keyword
  • Sealed 
  • Interface
  • None

30) Interface class can contains only properties, indexers, methods, delegates and events signature?

  • No 
  • Yes 
  • None 

31) Can we instantiate abstract class?

  • No 
  • Yes 
  • None 

32) Can be an abstract class as a sealed class?

  • No
  • Yes
  • None

33) Can be an abstract class inherited from more than one class?

  • No 
  • Yes 
  • None 

34) An abstract class can contain constructors and destructor?

  • No 
  • Yes 
  • None 

35) Can it an abstract method likely implicitly virtual method?

  • No 
  • Yes 
  • None

Conclusion (OOPS)

OOPS provides great capability with Re-usability, Inheritance, Data Hiding, Reduced complexity of a problem, Easy to Maintain and Upgrade, Modifiable and Message Passing to develop high quality software with cost cutting.

OOPS, IIS and Other ASP.Net Interview Questions and Answers:

MVC ASP.Net Interview Questions And Answers

In this article,  explaining best MVC ASP.Net Interview Questions and Answers as below. In my earliest article covered .Net framework OOPS interview questions:

1. Which is the best approach to assign a session in MVC?

A) System.Web.HttpContext.Current.Session["LoginID"] =7;
B) Current.Session["LoginID"] =7;
C) Session["LoginID"] =7;
D) None

2. RedirectToActionPermanent() Method for which Status code represents?

A) 304
B) 302
C) 301
D) 300
E) None

3. RedirectToAction() Method for which Status code represents?

A) 304
B) 302
C) 301
D) 300
E) None

Monday

What is the difference between an interface and abstract class?

Introduction

Interface and Abstraction can't be instantiated. Abstract class is likewise similar to interface until abstract class is implemented.  I have clarified in subtle element distinction between an interface and abstract class.


Abstract Interface Class


  1. Abstract class needs virtual strategy for its its usage in common behaviour. Interface class needn't bother with it.
  2. Abstract can’t be instantiated. Interface class furthermore can't be instantiated.
  3. Abstract class is idle till we tend to can’t decision from the derived category. Interface class moreover has indistinguishable component it's not being used till we tend to choice it from sub classes.
  4. Interface class is slower than abstract class. Abstraction class is far faster than interface class.
  5. Interface class needs its usage in sub classes so when we roll out any improvements in interface class we have to track down all implantation & carefully we have to make changes in the classes otherwise compiler will throw error. Abstraction class has default usage so it doesn't require finding all classes correspondingly. 
  6. Fields & constants can't be characterised in interface class. In abstraction class, we can characterise constants & fields.
  7. An interface class can't have access modifiers subs, functions; methods have by default public access modifiers.
  8. An interface class has not gave any code just can simply provide signatures.  Abstraction class has the ability to give its usage and have moreover the capacity to override its methods and functions etc.
  9. An interface class can be executed when units of functions are little. Abstraction class can be implemented when units of functions are enormous. This usage application turns out to be more flawless and clean with no unpredictability of code.

Conclusion

An Interface and Abstraction classes are implemented in the application to make code more vigorous, perfect and adaptable.

Suggested Reading

Friday

Interface class c#

Introduction

Interface class is an entity only not a class. Interface classes can not be implemented. Interface class can be implement in sub classes. Interface class can not be instantiated. Interfaces class is utilised in asp.net (C#) as a part of  ASP.Net has not capacity of multiple inheritances therefore interface classes are presented with awesome arrangement. With interface classes application turn out to be unpleasantly vigorous and appallingly adaptability in our application. Interfaces class is to a great degree supportive when we are utilising small units of functions, in alternative manner abstraction can be used when large units of functions are used.  A keyword “Interface” is characterise to define the class. Interface class is utilised n sub classes. Interface class has the ability to mark usage to signature implementation.  An interface class has not access modifiers, everything is accepted public.

Interface Class In C#

An interface class can be member of namespace or class can. Interface class can contain signatures for the accompanying individuals.

  • Members
  • Indexers
  • Properties
  • Events

A class ought to execute interface members are indicated in interface class. An illustration is offered underneath to clear more view about interface class.

Interface AbcInterface
{
          Void TestMethod();
}
Class Test: AbcInterface
{
      Void samplemethod()
      {
          //method implementation
      }
     Static Void Main()
    {
       //Declaring the interface instance
       AbcInterface obj = new Test ();
       //Calling the member
       Obj. TestMethod();
    }
}

Summary

In short, Interface class gives incredible adaptability to design application & reduces the complexity of the application. It is highly recommended to use object oriented mythologies (OOPS) to make make application more powerful with perfect and clean code. In my past article clarified about Abstraction class and completely step by step difference between Interface and Abstraction Class

Suggested Reading

Thursday

Abstraction class in c#

Introduction

Abstraction class is a special class that can't be instantiated. Abstraction class is used in ASP.net (c#) as a result of ASP.net has not multiple inheritances thus we will use abstraction classes as an alternative. Abstraction is inheritable through sub classes, functions, forms etc.  It's alternate to use multiple inheritances in ASP.net. Abstract will use its completely different modifiers specifies however in abstraction class this feature isn't enclosed in interface class. Abstraction class is quicker than interface class. Abstraction have implementation in class also. If we have to use common behaviour in our class then abstract class is better option. We can define abstract class with keyword Abstract class. If you are planning smaller units then use interface class if you use design large units of functions then use abstract class.

abstrac Class in C#


public abstract class TestClass
{
    // Class members can define here.
}
Abstract class can also defines abstract methods also. I have given very good example as given below.
public abstract class TestClass
{
    public abstract void DoTestwork(int j);
}

Abstract class have not implementation. Abstract class can override its methods from base class. When a abstract class inherits methods from its base class, abstract class can overrides its virtual methods class methods. I have provided a very good example for the same.

public class Test
{
    public virtual void DoSampleMethod(int j)
    {
        // Original implementation.
    }
}

public abstract class TestNew : Test
{
    public abstract override void DoWork(int i);
}

public class Funny : TestNew
{
    public override void DoSampleMethod(int j)
    {
        // New implementation.
    }
}

Summary

Explained with example Abstraction class in c#. I have already explained in detail Interface Class, difference between Interface and Abstraction Class and What is Boxing and Unboxing in ASP.Net with example.