CSharp Basic Interview Question 2021

Here are the top 76 basic C# interview question for the year 2021

1)How many Bytes are stored by 'Long' Data type in C# .net?
A]8
B]4
C]2
D]1
E]0

[Correct Answer : A]

2)Which data type should be more preferred for storing a simple number like 35 to improve execution speed of a program?
A]sbyte
B]short
C]int
D]long
E]decimal

[Correct Answer : A]

3)Which Conversion function of 'Convert.TOInt32()' and 'Int32.Parse()' is efficient?
  1) Int32.Parse() is only used for strings and throws argument exception for null string
  2) Convert.Int32() used for data types and returns directly '0' for null string
A]2
B]Both 1,2
C]1
D]None of the above
E]Both gives error

[Correct Answer : A]

4)What is the default type of number without decimal is?
A]Long Int
B]Unsigned Long
C]Int
D]Unsigned Int
E]float

[Correct Answer : C]

5)What is the number of digits upto which precision value of float data type is valid?
A]Upto 6 digit
B]Upto 10 digit
C]Upto 8 digit
D]Upto 9 digit
E]Upto 7 digit

[Correct Answer : E]

6)What is the default value of Boolean Data Type is?
A]0
B]true
C]false
D]1
E]null

[Correct Answer : C]

7)What is the Size of 'Char' datatype?
A]8 bit
B]12 bit
C]16 bit
D]20 bit
E]36 bit

[Correct Answer : C]

8)Which string method used to compare two strings with each other?
A]Compare To()
B]Compare()
C]Copy()
D]ConCat()
E]check()

[Correct Answer : B]


9)From below which is the correct statement about strings?
A]a string is created on the stack
B]a string is primitive in nature
C]a string created on heap
D]string on a stack or on a heap depends on the length of the string
E]None of the above

[Correct Answer : C]

10)Why do we need for Conversion of data type in C#?
A]To store a value of one data type into a variable of another data type
B]To get desired data
C]To prevent situations of runtime error during change or conversion of data type
D]To get output
E]None of the above

[Correct Answer : C]

11)What are the types of 'Data Conversion' in C#?
A]Implicit Conversion
B]Explicit Conversion
C]Data Conversion
D]Implicit Conversion and Explicit Conversion
E]None of the above

[Correct Answer : B]

12)Which is the  subset of int data type.
A]long, ulong, ushort
B]long, ulong, uint
C]long, float, double
D]long, float, ushort
E]long, float, string

[Correct Answer : C]

13)Which from below is the  correct way of incrementing the operators are ?
A]++ a ++
B]b ++ 1
C]c += 1
D]d =+ 1
E]C==+1

[Correct Answer : C]

14)Which of the following is/are not Relational operators in C#?
A]>=
B]<>=
C]Not
D]<=
E]><

[Correct Answer : B]

15)Which of the following options is not a Bitwise Operator in C#?
A]&, |
B]^, ~
C]<<, >>
D]+=, -=
E]*=,=

[Correct Answer : d]

16)Which of the following access specifier in C# allows a class to hide its member variables and member functions from other functions and objects?
A]Public
B]Private
C]Protected
D]Internal
E]None of the above

[Correct Answer : B]

17)Which of the following is the correct about static member variables of a class?
A]We can define class members variables as static using the static keyword.
B]The static keyword is used before the class keyword in a class definition to declare a static class.
C]A static class members are accessed by the class name followed by the member name. 
D]All of the above
E]None of the above

[Correct Answer : D]

18)In how many ways you can pass parameters to a method?
A]Value parameters
B]Reference parameters
C]Output parameters
D]All  of the above
E]None of the above

[Correct Answer : D]

19)What is the purpose of using statement in C#?
A]Using keyword is used to include a namespace in the program
B]Using keyword is used to include a class in the program
C]Using keyword is used to include a structure in the program
D]Using keyword is used to include a enum in the program
E]Using keyword is used to include a code in the program

[Correct Answer : A]

20)Which class acts as a base class for all the data types in .net?
A]String
B]int
C]dynamic
D]variable
E]object

[Correct Answer : E]


21)________type checking for these types of variables takes place at run-time.
A]Dynamic
B]Object
C]Variable
D]String
E]Char

[Correct Answer : A]

22)How encapsulation is implemented in C#?
A]using access specifiers.
B]using operators
C]using structure
D]using methods.
E]None of the above

[Correct Answer : A]


23)What is scope of a Internal member variable of a C# class?
A]Any member with internal access specifier can be accessed from any class/method within the application
B]Any member with internal access specifier can be accessed from any class/method outside the application
C]Any member with internal access specifier can be accessed across projects
D]All of the above
E]None of the above

[Correct Answer : A]


24)How to define nullable types in C# variable?
A]Nullable<Int32>
B]Int32<Nullable>
C]Null<bool>
D]bool<null>
E]null

[Correct Answer : A]


25)From below statement which is true for class and structure ?
A]Classes are reference types and structs are value types.
B]Structures do not support inheritance
C]Structures cannot have default constructor.
D]All of the above
E]None of the above

[Correct Answer : D]


26)Which of the folling sentence is correct for a enumeration in C#?
A]An enumeration is a set of named integer constants
B]An enumerated type is declared using the enum keyword
C]Enumerations are value data type
D]Enumeration contains its own values and cannot inherit.
E]All of the above

[Correct Answer : E]


27)What is the default access for a class?
A]public
B]private
C]protected
D]internal
E]void

[Correct Answer : D]


28)Below sentence is correct for function overloading?
A]You can have multiple definitions for the same function name in the same scope.
B]The mechanism of linking a function with an object during compile time is called function overloading
C]Implemented by abstract classes and virtual functions.
D]They cannot be be inherited
E]All of the above

[Correct Answer : A]


29)_______ is defined as a syntactical contract that all the classes.
A]Interface
B]Class
C]Abstract
D]Sealed
E]Structure

[Correct Answer : A]


30)How we can declare an array in C# ?
A]datatype[] arrayName
B]arrayName datatype[]
C]datatype arrayName
D]datatype[arrayName] 
E]None of the above

[Correct Answer : A]


31)Which satatement is true for finally in try catch exception handling.
A]It never executes
B]If catch executes then finally block is skipped
C]Finally always executes.whether an exception is thrown or not thrown
D]Finally block never gets executed
E]All of the above

[Correct Answer : C]


32)Which class Handles I/O errors.
A]System.IndexOutOfRangeException
B]System.IO.IOException
C]System.ArrayTypeMismatchException
D]System.NullReferenceException
E]System.DivideByZeroException

[Correct Answer : B]


33)Waht is the return type of C# IsMatch(string input) function
A]String
B]Number
C]Boolean
D]Long
E]Float

[Correct Answer : C]


34)An ___________ is a declarative tag that is used to convey information to runtime about the behaviors of various 
    elements like classes, methods, structures, enumerators, assemblies etc
A]Attribute
B]Function
C]Value
D]Application
E]Enum

[Correct Answer : A]


35)________ objects are used for obtaining type information at runtime.
A]Attribute
B]Reflection 
C]Reflect
D]Relation
E]Class

[Correct Answer : B]


36)From below which is the application of Reflection ?
A]It allows view attribute information at runtime
B]It allows examining various types in an assembly and instantiate these types
C]It allows late binding to methods and properties
D]It allows creating new types at runtime and then performs some tasks using those types
E]All of the above

[Correct Answer : E]


37)_______ are named members of classes, structures, and interfaces
A]Properties
B]Reflection
C]Application
D]Relation
E]Objects

[Correct Answer : A]


38)An abstract class may have an _________ property
A]public
B]static
C]internal
D]abstract
E]extended

[Correct Answer : D]


39)An _______ allows an object to be indexed such as an array.
A]indexer
B]syntaxer
C]index
D]arrayindex
E]indexable

[Correct Answer : A]


40)A _______ is a reference type variable that holds the reference to a method
A]Function
B]Delegate
C]indexer
D]abstract
E]Events

[Correct Answer : B]

41)Choose the correct statement among the followings?
A]Indexers are location indicators
B] Indexers are used to access class objects
C] Indexer is a form of property and works in the same way as a property
D]All of the above 
E]None of the above

[Correct Answer : D]


42)Choose the statement which is incorrect?
A]try block does not need to be followed by catch block
B]try block can be followed by finally block instead of catch block
C]try can be followed by both catch and finally block
D]try need not to be followed by anything
E]All of the above

[Correct Answer : D]


43)Which among the following cannot be a target for a custom attribute?
A]Enum
B]Event
C]Interface
D]Class
E]Namespace

[Correct Answer : E]


44)Attributes could be applied to ___________ ?
A]Method
B]Class
C]Assembly
D]Interface
E]All of the above

[Correct Answer : E]


45)To implement delegates, the necessary condition is?
A]Class declaration
B]Inheritance
C]Runtime Polymorphism
D]Exceptions
E]Runtime Encapsulation

[Correct Answer : A]


46)To generate a simple notification for an object in runtime, the programming construct to be used for implementing this idea?
A]Namespace
B]Interface
C]Delegate
D]Attribute
E]Indexes

[Correct Answer : C]


47)Choose the incorrect statement among the following about the delegate?
A]Delegates are of reference types
B]Delegates are object oriented
C]Delegates are type safe
D]Delegates are the library class in System namespace
E]All of the above

[Correct Answer :E]


48)What is meant by the term generics?
A]Parameterized types
B]Class
C]Structure
D]Interface
E]Namespace

[Correct Answer : A]


49)Which among the below classes is present in System.Collection.Generic namespace?
A]Stack
B]Tree
C]Sorted Array
D]List
E]All of the above

[Correct Answer : A]


50)Which of these type parameters is used for generic methods to return and accept any type of object?
A]A
B]B
C]F
D]T
E]C

[Correct Answer : D]


51)Choose the wrong statement about the LINQ?
A]The main concept behind the linq is query
B]Linq makes use of foreach loop to execute the query
C]It is not required that linq should make use of IEnumerable interface
D]All of the above
E]None of the above

[Correct Answer : C]


52)In which namespace the interface IEnumerable is declared?
A]System.Collections
B]System.Collections.Generic
C]System.Mvc.Generic
D]Both System.Collections & System.Collections.Generic
E]None of the above

[Correct Answer : b]


53)Which namespace should be included while making use of LINQ operations?
A]System.Text
B]System.Collections.Generic
C]System.Linq
D]System.Generic
E]System.Generic.Collection

[Correct Answer : C]


54)Which class is the base class for all arrays in C#?
A]Array
B]Text
C]Arrays
D]Both Array & Text
E]None of the above

[Correct Answer : A]


55)What is an iterator?
A]A method
B]An operator
C]Accessor
D]All of the above
E]None of the above

[Correct Answer : D]

56)What is Recursion in C# defined as?
A]Recursion is another form of class
B]Recursion is another process of defining a method that calls other methods repeatedly
C]Recursion is a process of defining a method that calls itself repeatedly
D]Recursion is a process of defining a method that calls other methods which in turn calls this method
E]None of the above

[Correct Answer : C]


57)Which is the correct statement about constructor overloading in C# is?
A]Overloaded constructors have the same name as the class
B]Overloaded constructors cannot use optional arguments
C]Overloaded constructors can have different type of number of arguments as well as differ in number of arguments
D]All of the above
E]None of the above

[Correct Answer : C]


58)Which of the following is not a namespace in the .NET Framework Class Library?
A]System.Process
B]System.Security
C]System.Threading
D]System.xml
E]System.Data

[Correct Answer : A]

59)Which among the below does not belong to the C# namespace?
A]class
B]struct
C]enum
D]data
E]var

[Correct Answer : D]


60)Which among the below statements are not correct about a namespace used in C#?
A]Nested namespaces are allowed
B]Importing outer namespaces imports inner namespace
C]Nested namespaces are allowed
D]Importing outer namespace does not import inner namespace
E]All of the above

[Correct Answer :B]


61)Which from below is the collection class in C#.
A]ArrayList
B]Hashtable
C]SortedList
D]Stack
E]All of the above

[Correct Answer : E]


62)When you add an item in the queue, it is called _______
A]enqueue
B]deque
C]remove
D]added
E]queue

[Correct Answer : A]


63)From below option which is the correct syntax of statement Lambda expression ?
A]input > { statements }
B]input => expression
C]input => { statements }
D]input = { statements }
E]input ==> { statements }

[Correct Answer : C]


64)From below which is the correct form  lambda expression ?
A]Expression lambda
B]Settlement lambda
C]Express lambda
D]Situation lambda
E]None of the above

[Correct Answer : A]


65)The ____ language allows more than one method in a single class
A]C#
B]J#
C]C++
D]C
E]None of the above

[Correct Answer : A]


66)The character pair ?: is a________________available in C#.
A]Unary operator
B]Ternary operator
C]Decision operator
D]Functional operator
E]Arthimetic operator

[Correct Answer : B]


67)_______ variables are visible only in the block they are declared.
A]System
B]Global
C]Local
D]Console
E]Universal

[Correct Answer : C]


68)A variable which is declared inside a method is called a________variable
A]Local
B]Private
C]Static
D]Serial
E]Sequence

[Correct Answer : A]


69)Two methods with the same name but with different parameters.
A]Overloading
B]Multiplexing
C]Duplexing
D]Loading
E]None of the above

[Correct Answer : A]


70)An instance variable
A]is an object of a class
B]represents an attribute of an object
C]is a method of a class
D]a and c
E]a nd b

[Correct Answer : B]


71)A delegate defines
A]a Wahsington representative
B]a class that encapsulates methods
C]a means of passing arrays into methods
D]a substitue for an inherited method
E]a parameter object

[Correct Answer : B]


72)Every class directly or indirectly extends the______class.
A]System
B]Object
C]Drawing
D]Console
E]None of the above

[Correct Answer : B]


73)A method_____an exception when that method detects that a problem has occured.
A]Trys
B]Catches
C]Throws
D]a and b
E]b and c

[Correct Answer : C]


74)Exception objects are derived from the class.
A]Try
B]Catch
C]Exception
D]Event
E]System

[Correct Answer : C]


75)An abstract class
A]A. may contain instance variables
B]may contain constructors
C]may extend another class
D]a and b
E]all of the above

[Correct Answer : e]

76)A____block enclose the code that could throw an exception.
A] Try
B] Catch
C] Exception
D] Error
E] a and b

[Correct Answer : A]
 

Scroll to Top