AmbitionBox
Discover Best Places to work in India
Discover best places to work
Compare & find best workplace
Bring your workplace to life
Highlight your company's perks
Read reviews for 6L+ companies
Rate your former or current company
Discover salaries for 8L+ companies
Calculate your take home salary
Check your market value
Help other jobseekers
Read interviews for 90K+ companies
Interviews questions for 1K+ colleges
Contribute your interview questions
C# Programming
Choose the correct output for the given set of code:
class program
{
staticvoid main(string[] args)
int i =5;
int v =40;
int[] p =newint[4];
try
p[i]= v;
}
catch(IndexOutOfRangeException e)
Console.WriteLine("Index out of bounds");
Console.WriteLine("Remaining program");
value 40 will be assigned to a[5];
The output will be : Index out of bounds Remaining program
The output will be : Remaining program
None of the above mentioned
Answer: Option (B)
staticvoid Main(string[] args)
Console.WriteLine("csharp"+" "+1/Convert.ToInt32(0));
catch(ArithmeticException e)
Console.WriteLine("Java");
Console.ReadLine();
csharp
java
Run time error
csharp 0
1 / 0, hence system out of flow exception error.
Choose the correct statement among the following which supports the fact that C# does not allow the creation of empty structures?
C#.NET supports creation of abstract user-defined data types using structures
By having empty structures,it would mean that the new data types have no data associated with, which does not make any sense in C#.NET
Basic reason to create structures is the inability to represent real life objects using standard data types offered by the language
All of the above mentioned
Basic definition of structures in C#.NET.
Which of the following is a correct statement about the C#.NET code given below?
struct book
privateString name;
privateint pages;
private Single price;
book b =new book();
New structure can be inherited from struct book
When the program terminates, variable b will get garbage collected
The structure variable ‘b’ will be created on the stack
Answer: Option (C)
Choose the correct statement about structures as to why they are defined as value types but not reference types?
Since space required for structure variables is allocated on stack which is a form of memory that is automatically available when a variable to be used is in scope
Structures generally are used to represent user defined data types that consists of small amount of data in them.Hence using stack for declaration of such variables is not a problem.
All of the mentioned
None of the mentioned
Which of the following is the correct way to settle down values into the structure variable ‘e’ defined in the following code snippet?
struct emp
publicString name;
publicint age;
public Single sal;
emp e =new emp();
e.name = “Ankit”; e.age = 24; e.sal = 200;
With emp e { .name = “Ankit”; .age = 24; .sal = 200; }
name = “Ankit”; age = 24; sal = 200;
Answer: Option (A)
Select the correct statements among the following?
A structure can contain properties
A structure can contain constructors
A structure can contain protected data members
A structure cannot contain constants
Answer: Option (A) and Option (B)
class trial
int i;
float d;
struct sample
privateint x;
private Single y;
private trial z;
sample s =new sample();
trial object referred by z is created on the stack
z is created on the heap
Both s and z will be created on the heap
s will be created on the stack
Answer: Option (D)
Choose the correct statement about structures in C#.NET?
Structures can be declared within a procedure
Structures can implement an interface but they cannot inherit from another structure
Structure members cannot be declared as protected
A structure can be empty
Answer: Option (B) and Option (C)
Calculate the number of bytes a structure variable s occupies in the memory if it is defined as follows.
class abc
Decimal d;
24 bytes
8 bytes
16 bytes
12 bytes
Join India’s largest community to research company culture
Are you a student or working professional?
Student/Never worked
I am a student/I have never worked
Working Professional
I am working/I have worked before
What are your preferred job locations?
Popular Cities
Other Cities
Follow your preferred designations/job profiles
Suggestions based on your job profile
vs
Similar Companies