php mcq questions with answers
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();
A.20 bytesB.12 bytesC.8 bytesD.16 bytesE.24 bytes
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;
A.All elements of a will get copied into corresponding elements of b.B.Address stored in a will get copied into b.C.Once assignment is over a will get garbage collected.D.Once assignment is over a will go out of scope, hence will die.E.Address of the first element of a will get copied into b.
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.
A.1, 2B.3, 4C.1, 2, 4D.3, 5
C#.NET structures are always value types.
A.TrueB.False
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();
A.The structure variable b will be created on the heap.B.We can add a zero-argument constructor to the above structure.C.When the program terminates, variable b will get garbage collected.D.The structure variable b will be created on the stack.E.We can inherit a new structure from struct Book.