C# - Structures Questions and Answers
Practice ModeShowing 10 of 39 questions
Q1
The space required for structure variables is allocated on stack.
Answer: Option A
Q2
Creating empty structures is allowed in C#.NET.
Answer: Option B
Q3
Which of the following statements is correct about the C#.NET code snippet given below?
class Trial
{
int i;
Decimal d;
}
struct Sample
{
private int x;
private Single y;
private Trial z;
}
Sample ss = new Sample();
Answer: Option
Q4
How many bytes will the structure variable samp occupy in memory if it is defined as shown below?
class Trial
{
int i;
Decimal d;
}
struct Sample
{
private int x;
private Single y;
private Trial z;
}
Sample samp = new Sample();
Answer: Option B
Q5
Which of the following will be the correct result of the statement b = a in the C#.NET code snippet given below?
struct Address
{
private int plotno;
private String city;
}
Address a = new Address();
Address b;
b = a;
Answer: Option A
Q6
Which of the following statements are correct?
A struct can contain properties.
A struct can contain constructors.
A struct can contain protected data members.
A struct cannot contain methods.
A struct cannot contain constants.
Answer: Option A
Q7
C#.NET structures are always value types.
Answer: Option A
Q8
When would a structure variable get destroyed?
Answer: Option C
Q9
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();
Answer: Option D
Q10
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();
Answer: Option D