Home » Aptitude Questions and Answers » C# Aptitude Questions and Answers

C# Class & Object Aptitude Questions and Answers | Set 5

C# Class & Object Aptitude Questions | Set 5: This section contains aptitude questions and answers on C# Class & Object.
Submitted by Nidhi, on April 12, 2020

1) What are the correct statements about given code snippets?
using System;

public class Example
{
    public virtual static void SayHello()
    {
        Console.Write("Hello World");
    }
    
    static void Main(string[] args)
    {
        SayHello();
    }
}
  1. Hello World
  2. HelloWorld
  3. Syntax Error
  4. Runtime Exception

2) What is the correct output of given code snippets?
using System;

public class Example
{
    public virtual void SayHello()
    {
        Console.Write("Hello World");
    }
    
    static void Main(string[] args)
    {
        Example Ob = new Example();
        Ob.SayHello();
    }
}
  1. Hello World
  2. HelloWorld
  3. Syntax Error
  4. Runtime Exception

3) We can use the override keyword to declare a method in a class?
  1. Yes
  2. No

4) What is the correct output of given code snippets?
using System;

public class Example
{
    public override void SayHello()
    {
        Console.Write("Hello World");
    }
    
    static void Main(string[] args)
    {
        Example Ob = new Example();
        Ob.SayHello();
    }
}
  1. Hello World
  2. HelloWorld
  3. Syntax Error
  4. Runtime Exception

5) What is the correct output of given code snippets?
using System;

public class Example
{
    public void SayHello()
    {
        Console.Write("Hello World");
    }
    
    static void Main(string[] args)
    {
        static Example Ob = new Example();
        Ob.SayHello();
    }
}
  1. Hello World
  2. Hello world
  3. Syntax Error
  4. Runtime Exception






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.