×

Multiple-Choice Questions

Web Technologies MCQs

Computer Science Subjects MCQs

Databases MCQs

Programming MCQs

Testing Software MCQs

Digital Marketing Subjects MCQs

Cloud Computing Softwares MCQs

AI/ML Subjects MCQs

Engineering Subjects MCQs

Office Related Programs MCQs

Management MCQs

More

Which is the correct way to declare an object of the class in C#?

72. Which is the correct way to declare an object of the class in C#?

  1. Class_Name Object_Name = new Class_Name();
  2. Class_Name Object_Name;
  3. new Object_Name as Class_Name();
  4. Both A and B

Answer: A) Class_Name Object_Name = new Class_Name();

Explanation:

The correct way to declare an object of the class in C# is:

Class_Name Object_Name = new Class_Name();

Consider the below example:

using System;

namespace MyApplication {
  class Mobiles {
    string brand = "Apple";

    static void Main(string[] args) {
      Mobiles mobile = new Mobiles();
      Console.WriteLine(mobile.brand);
    }
  }
}

// Output: Apple

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.