Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
4 views34 pages

Top 10 .NET Interview Questions For 0-2 Years Experience

The document provides an overview of Object-Oriented Programming (OOP), detailing its main concepts such as classes, objects, inheritance, polymorphism, encapsulation, and exception handling. It explains the advantages of OOP, differences between method overloading and overriding, and contrasts abstract classes with interfaces. Additionally, it covers SQL joins and the differences between stored procedures and functions.

Uploaded by

dummy dummy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views34 pages

Top 10 .NET Interview Questions For 0-2 Years Experience

The document provides an overview of Object-Oriented Programming (OOP), detailing its main concepts such as classes, objects, inheritance, polymorphism, encapsulation, and exception handling. It explains the advantages of OOP, differences between method overloading and overriding, and contrasts abstract classes with interfaces. Additionally, it covers SQL joins and the differences between stored procedures and functions.

Uploaded by

dummy dummy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

Q. What is OOPS?

What are the main concepts


of OOPS?
Q2. What is OOPS? What are the main concepts of
OOPS?
❖ OOP stands for Object-Oriented Programming,
which means it is a way to create software around
objects.

❖ OOPs provide a clear structure for the software's


and web applications.
Q. What are the advantages of OOPS?

❖ Advantages of OOPS:

1. Reuse of code using inheritance.

2. Flexibility of code using polymorphism.

3. Secure application by using Encapsulation.

4. Easily scalable from small to large


applications.

5. Easier troubleshooting of code because of


modularity.
Q. What are Classes and Objects?

Q5. What are Classes and Objects?


❖ A class is a LOGICAL UNIT or BLUEPRINT. It contains
fields, methods and properties.

❖ Class members are:

1. A constructor is a method in the class which gets executed


when a class object is created.

2. A field is a variable of any type. It is basically the data.

3. A property is a member that provides helps in read and


write of private field.

4. A method is a code block that contains a series of


statements.
Q. What are Classes and Objects?

Q5. What are Classes and Objects?


Q. What are Classes and Objects?

❖ Object - An object is an INSTANCE of a class.

Object
Q. What are Classes and Objects?
Q . What is Inheritance? When to use Inheritance?

❖ Inheritance is creating a PARENT-CHILD relationship


between two classes, where child class will
automatically get the properties and methods of the
parent.

❖ Inheritance is good for: REUSABILITY and


ABSTRACTION of code
Q . What is Inheritance? When to use
Inheritance?

Base/ Parent/
Super class

Derived/ Child/
Sub class

CalculateSalary() method is not


present in PermanentEmployee
class, but it will get it
automatically from it’s parent
Q. What are the different types of Inheritance?
Q. What are the different types of Inheritance?
Q. What are the different types of Inheritance?
Q. What is Method Overloading? In how many
ways a method can be overloaded?

❖ Method overloading is a type of polymorphism in


which we can create multiple methods of the same
name in the same class, and all methods work in
different ways.
Q. What is the difference between Overloading
and Overriding?

❖ Method Overloading

1. Multiple methods of same name in single


class.

2. No need of inheritance, as it is in single class.

3. All methods have different signature.

4. It’s a compile time polymorphism.

5. No special keyword used.


Q. What is the difference between Overloading
and Overriding?

❖ Method Overriding

1. Multiple methods of same name in different


class.

2. Inheritance is used, as it is in different class.

3. All methods have same signature.

4. It’s a run time polymorphism.

5. Virtual & override keywords.


Q.What is the difference between an Abstract class
and an Interface (atleast 4)?

1. Abstract class contains both DECLARATION &


DEFINITION of methods.

Method Declared

Method Defined

2. Abstract class keyword: ABSTRACT


Q.What is the difference between an Abstract class
and an Interface (atleast 4)?
Q27. What is the difference between Abstract class and
an Interface?
1. Interface should contain DECLARATION of methods.

❖ With C# 8.0, you can now have default


implementations/ definition of methods in
an interface. But that is recommended in
special case*.

Only method
Declaration is allowed

2. Interface keyword: INTERFACE


Q. What is the difference between an Abstract
class and an Interface (atleast 4)?

3. Abstract class does not support multiple


inheritance
Q. What is the difference between an Abstract
class and an Interface (atleast 4)?

3. Interface supports multiple inheritance.


Q. What is the difference between an Abstract
class and an Interface (atleast 4)?

4. Abstract class can have constructors.


Q. What is the difference between an Abstract
class and an Interface (atleast 4)?

4. Interface do not have constructors.


Q. What is the difference between an Abstract
class and an Interface (atleast 4)?

Abstract Class Interface

1. Abstract class Mostly Interfaces contain


contains both DECLARATION of
DECLARATION & methods. From C# 8.0
DEFINITION of definition is also possible.
methods.

2. Abstract class 2. Interface keyword:


keyword: ABSTRACT INTERFACE

3. Abstract class does 3. Interface supports


not support multiple multiple inheritance.
inheritance

4. Abstract class can 4. Interface do not have


have constructors. constructors.
Q. What is the difference between “String”
and “StringBuilder”?

❖ String is IMMUTABLE in C#.

It means if you defined one string then you couldn’t modify


it. Every time you will assign some value to it, it will create a
new string.

Both these strings


are different and
occupy different
memory in process
Q. What is the difference between “String”
and “StringBuilder”?

❖ StringBuilder is MUTABLE in C#.

This means if any manipulation will be done on


string, then it will not create a new instance every
time.

Only one string in


memory.
Q. How to implement Exception Handling in C#?

❖ Exception handling in Object-Oriented


Programming is used to MANAGE ERRORS.

1. TRY − A try block is a block of code inside


which any error can occur.

1. CATCH − When any error occur in TRY block


then it is passed to catch block to handle it.

2. FINALLY − The finally block is used to execute


a given set of statements, whether an
exception occur or not.
Q. How to implement Exception Handling in C#?
Q. What is a Constructor? When to use
constructor in real applications?

❖ A constructor is a specialized method in the class which


gets executed when a class object is created.

❖ Constructor name will same as of Class name.

❖ A constructor is used to set default values for the class.


Q. What are the types of constructor?

Q66. What are the types of constructor?


Q . What is the purpose of “using” keyword in
C#?

❖ There are two purpose of using keyword in C#:


1. USING DIRECTIVE

2. USING STATEMENT - The using statement ensures


that DISPOSE() method of the class object is called
even if an exception occurs.
Q. What are the types of Joins in SQL Server?

❖ Left outer join - A left join returns all the rows from the
left table, along with any matching rows from the right
table.

❖ Right outer join - A right join returns all the rows from
the right table, along with any matching rows from the
left table.
Q. What are the types of Joins in SQL Server?

Q129. What are the types of Joins in SQL Server?

❖ Full outer join - A full outer join returns all the rows
from both the left and right tables in the join.

❖ Inner join - An inner join returns only the


common rows from both tables that meet the
join condition.
Q. What is the difference between Stored
Procedure and Functions (at least 3)?

Stored Procedure Function

1. SP may or may not return Function must return a


a value value

2. Can Only has input


have input/output paramet parameters
ers

3. We can Cannot call SP insied a


call function inside SP function

4. We cannot use SP in SQL We can use them with


statements like SELECT, function.
INSERT, UPDATE, DELETE, SELECT *, dbo.fnCountr
MERGE, etc. y(city.long) FROM city;

5. We can use try-catch We can not use try-


exception handling in SP catch in functions

6. We can use transactions We can not use


inside SP. transactions
inside functions.
Q. What is the difference between Stored
Procedure and Functions (at least 3)?

CREATE PROCEDURE proc_name


(@Ename varchar(50),
@EId int output)
AS
BEGIN

INSERT INTO Employee (EmpName)


VALUES (@Ename)
SELECT @EId= SCOPE_IDENTITY()

END

CREATE FUNCTION function_name


(parameters) --only input parameter
RETURNS data_type AS
BEGIN

-- SQL statements
RETURN value

END;

You might also like