csharp_onlinetest.md - brainchildservices/curriculum GitHub Wiki

ONLINE TEST

SLIDE-1

  1. Which of the following keyword is used for including the namespaces in the program in C#?

    1. imports
    2. using
    3. exports
    4. None of the above.

SLIDE-2

  1. How many Bytes are stored by β€˜Long’ Data type in C# .net?

    1. 8
    2. 4
    3. 2
    4. 1

SLIDE-3

  1. Correct Declaration of Values to variables β€˜a’ and β€˜b’?

    1. int a = 32, b = 40.6;
    2. int a = 42; b = 40;
    3. int a = 32; int b = 40;
    4. int a = b = 42;

SLIDE-4

  1. What will be the error in the following C# code?

                 Static Void Main(String[] args)
    
                 {
                 
                     const int m = 100;
    
                     int n = 10;
    
                     const int k = n / 5 * 100 * n ;
    
                     Console.WriteLine(m * k);
    
                     Console.ReadLine();
    
                 }
    
    1. β€˜k’ should not be declared constant
    2. Expression assigned to β€˜k’ should be constant in nature
    3. Expression (m * k) is invalid
    4. β€˜m β€˜ is declared in invalid format

SLIDE-5

  1. Arrange the following data type in order of increasing magnitude sbyte, short, long, int.

    1. long < short < int < sbyte
    2. sbyte < short < int < long
    3. short < sbyte < int < long
    4. short < int < sbyte < long

SLIDE-6

  1. Which data type should be more preferred for storing a simple number like 35 to improve execution speed of a program?

    1. sbyte
    2. short
    3. int
    4. long

SLIDE-7

  1. Correct way to define a value 6.28 in a variable β€˜pi’ where value cannot be modified?

    1. #define pi 6.28F
    2. pi = 6.28F
    3. const float pi = 6.28F
    4. const float pi; pi = 6.28F

SLIDE-8

  1. What will be the output of the following C# code?

                 public static void Main(string[] args)
    
                 {
                 
                     double ZERO = 0;
    
                     Console.WriteLine("RESULT OF DIVISION BY ZERO IS :{0}",  (0 / ZERO));
    
                     Console.ReadLine();
    
                 }
    
    1. 1
    2. exception argument is thrown
    3. NaN
    4. 0

SLIDE-9

  1. What will be the output of the following C# code?

                 static void Main(string[] args)
    
                 {
                 
                     string s1 = "Delhi";
    
                     string s2;
    
                     s2 = s1.Insert (6, "Jaipur");
    
                     Console.WriteLine(s2);
    
                 }
    
    1. DelhJaipuri
    2. Delhi Jaipur
    3. Delhi
    4. DelhiJaipur

SLIDE-10

  1. What will be the output of the following C# code?

                string s1 = " I AM BEST ";
    
                string s2;
    
                s2 = s1.substring (5, 4);
    
                Console.WriteLine (s2);
    
  • AM BEST
  • I AM BES
  • BEST
  • I AM

SLIDE-11

  1. Correct statement about strings are?
  • a string is created on the stack
  • a string is primitive in nature
  • a string created on heap
  • created of string on a stack or on a heap depends on the length of the string

SLIDE-12

  1. Storage location used by computer memory to store data for usage by an application is?
  • Pointers
  • Constants
  • Variable
  • none of above

SLIDE-13

  1. What will be the output of the following C# code?

                static void Main(string[] args)
    
                {
                
                    String name = "Dr.Strange";
    
                    Console.WriteLine("Good Morning" + name);
    
                }
    
  • Dr.Strange
  • Good Morning
  • Good Morning Dr.Strange
  • Good Morning name

SLIDE-14

  1. Default Type of number without decimal is?
  • Long Int
  • Unsigned Long
  • Int
  • Unsigned Int

SLIDE-15

  1. What is the actual type of string in C#?
  • System.Array
  • System.char
  • System.String
  • None of the mentioned

REF link: