Structures

Q1:
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();
  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.

A 1, 2

B 1, 3, 5

C 2, 4

D 3, 4, 5

ANS:A - 1, 2

No answer description is available. Let's discuss.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.