01 CSharp
01 CSharp
• .cs
• .exe
• .dll
• .txt
Correct Answer: .cs
• struct
• interface
• class
• namespace
Correct Answer: class
• public
• private
• protected
• internal
Correct Answer: private
• Start()
• Main()
• Run()
• Init()
Correct Answer: Main()
• string
• int
• object
• class
Correct Answer: int
• &
• .
• %
Correct Answer: +
• boolean
• bit
• bool
• flag
Correct Answer: bool
• int
• float
• string
• bool
Correct Answer: string
• extends
• :
• implements
Correct Answer: :
• const
• final
• readonly
• static
Correct Answer: const
• try
• catch
• finally
• 2 bytes
• 4 bytes
• 8 bytes
• public
• private
• protected
• transient
Correct Answer: transient
15. How do you create a new object of a class in C#?
• new ClassName()
• create ClassName()
• ClassName.new()
• ClassName()
Correct Answer: new ClassName()
• System
• Microsoft
• CSharp
• Base
Correct Answer: System
• true
• false
• null
• 0
Correct Answer: false
• func
• method
• void
• def
Correct Answer: void
• for
• while
• do-while
• foreach
Correct Answer: None, all are present
• interface
• class
• struct
• enum
Correct Answer: interface
22. What is the keyword used to prevent a class from being inherited?
• sealed
• static
• abstract
• private
Correct Answer: sealed
• ??
• ??=
• ?:
• ::
Correct Answer: ??
• Start()
• Run()
• Execute()
Correct Answer: Start()
• async
• await
• defer
• int?
• int
• int!
• nullable<int>
Correct Answer: int?
27. What will happen if you try to divide an integer by zero in C#?
• Returns 0
• Throws DivideByZeroException
• Returns infinity
• Compilation error
Correct Answer: Throws DivideByZeroException
• _myVar
• 2ndValue
• value1
• firstName
Correct Answer: 2ndValue
29. Which collection type stores key-value pairs?
• List
• Dictionary
• Array
• Queue
Correct Answer: Dictionary
• exit
• break
• continue
• return
Correct Answer: break
• 10
• 55
• Error
• 55
Correct Answer: 55
• ToInt()
• Convert.ToInt32()
• ParseInt()
• Int.Parse()
Correct Answer: Both Convert.ToInt32() and Int.Parse()
• [Deprecated]
• [Obsolete]
• [Ignore]
• [Hide]
Correct Answer: [Obsolete]
• Imports namespaces
• Declares variables
• Constructors
• Operators
• Properties
• Destructors
Correct Answer: Destructors
• System.Error
• System.Exception
• System.BaseException
• System.Catch
Correct Answer: System.Exception
• delegate
• func
• lambda
• anonymous
Correct Answer: delegate
• Defines a constant
• Defines a pointer
Correct Answer: Enables implicit typing
• A value type
• A pointer
• An exception handler
Correct Answer: A reference type to methods
40. What keyword is used to define a constant field that is evaluated at runtime?
• const
• readonly
• static
• sealed
Correct Answer: readonly
41. Which method in C# is called when an object is destroyed by the garbage collector?
• Finalize()
• Dispose()
• Destructor()
• Cleanup()
Correct Answer: Finalize()
42. Which of these access modifiers allow access within the same assembly but not from other
assemblies?
• private
• protected
• internal
• public
Correct Answer: internal
• 5
• 6
• Error
• Undefined
Correct Answer: 6
• ++
• &&
• ||
• ?:
Correct Answer: ++
• select
• where
• order by
• from
Correct Answer: where
• public
• private
• protected
• internal
Correct Answer: public
47. What keyword is used to inherit from a base class in C#?
• inherits
• extends
• :
• base
Correct Answer: :
• int
• char
• float
• real
Correct Answer: real
49. Which of these is used to handle multiple exceptions in a single catch block?
• // comment
• /* comment */
• comment