C# Programming - Structures
Exercise : Structures - General Questions
- Structures - General Questions
11.
When would a structure variable get destroyed?
12.
Which of the following statements is correct about the C#.NET code snippet given below?
struct Book
{
private String name;
private int noofpages;
private Single price;
}
Book b = new Book();
13.
Which of the following will be the correct output for the C#.NET program given below?
namespace IndiabixConsoleApplication
{
struct Sample
{
public int i;
}
class MyProgram
{
static void Main(string[] args)
{
Sample x = new Sample();
x.i = 10;
fun(ref x);
Console.Write(x.i + " ");
}
public static void fun(ref Sample y)
{
y.i = 20;
Console.Write(y.i + " ");
}
}
}
14.
Which of the following statements is correct?
15.
Which of the following statements are correct about the structure declaration given below?
struct Book
{
private String name;
protected int totalpages;
public Single price;
public void Showdata()
{
Console.WriteLine(name + " " + totalpages + " " + price);
}
Book()
{
name = " ";
totalpages = 0;
price = 0.0f;
}
}
Book b = new Book();
- We cannot declare the access modifier of totalpages as protected.
- We cannot declare the access modifier of name as private.
- We cannot define a zero-argument constructor inside a structure.
- We cannot declare the access modifier of price as public.
- We can define a Showdata() method inside a structure.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers