adplus-dvertising
frame-decoration

Question

Which of the following statements are correct about the structure declaration given below?

1. We cannot declare the access modifier of totalpages as protected.
2. We cannot declare the access modifier of name as private.
3. We cannot define a zero-argument constructor inside a structure.
4. We cannot declare the access modifier of price as public.
5. We can define a Showdata() method inside a structure.

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();

a.

1, 2

b.

1, 3, 5

c.

2, 4

d.

3, 4, 5

Posted under C# programming

Answer: (b).1, 3, 5

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Which of the following statements are correct about the structure declaration given below? 1. We cannot declare the access modifier of totalpages as protected. 2. We cannot...

Similar Questions

Discover Related MCQs

Q. Which of the following are true about classes and struct?

1. A class is a reference type, whereas a struct is a value type.
2. Objects are created using new, whereas structure variables can be created either using new or without using new.
3. A structure variable will always be created slower than an object.
4. A structure variable will die when it goes out of scope.
5. An object will die when it goes out of scope.

Q. The [Serializable()] attribute gets inspected at

Q. Which of the following are correct ways to specify the targets for a custom attribute?

Q. Which of the following is correct ways of applying an attribute?

Q. Which of the following statements are correct about Attributes used in C#.NET?

Q. Which of the following forms of applying an attribute is correct?

Q. Which of the following correctly describes the contents of the filename AssemblyInfo.cs?

Q. It possible to create a custom attribute that can be applied only to specific programming element(s) like ____ .

Q. Which of the following CANNOT be a target for a custom attribute?

Q. Once applied which of the following CANNOT inspect the applied attribute?

Q. Which of the following is the correct way to apply an attribute to an Assembly?

Q. Attributes can be applied to
1. Method
2. Class
3. Assembly
4. Namespace
5. Enum

Q. Select the class which is the base class for all arrays in C#?

Q. Select the interfaces implemented by array class:

Q. Choose the correct statement about the IComparer interface in C#:

Q. Choose the correct statement about the IComparer interface in C#:

Q. What does the following property defined in the array class defines in C#?

public bool IsReadOnly { get; }

Q. What does the following property define in C#?

public static int BinarySearch<T>(T[] array, int index, int length, T value)

Q. Which method will be used to copy content from one array to another array?

Q. Which mechanism among the following helps in identifying a type during the execution of a program?