Copyrights © 2012 Jatin Kotadiya. All Rights Reserved . Powered by Blogger.

Monday, November 12, 2012

C#

100. Creating empty structures is allowed in C#.NET?

A.True   
B.False
Answer: Option B

99.The space required for structure variables is allocated on stack?

A.True   
B.False
Answer: Option A

98.Which of the following statements are correct?

1.String is a value type.
2.String literals can contain any character literal including escape sequences.
3.The equality operators are defined to compare the values of string objects as well as references.
4.Attempting to access a character that is outside the bounds of the string results in an IndexOutOfRangeException.
5.The contents of a string object can be changed after the object is created.
A.1, 3
B.3, 5
C.2, 4
D.1, 2, 4
Answer: Option C

97.Which of the following statements are correct about the String Class in C#.NET?

1.Two strings can be concatenated by using an expression of the form s3 = s1 + s2;
2.String is a primitive in C#.NET.
3.A string built using StringBuilder Class is Mutable.
4.A string built using String Class is Immutable.
5.Two strings can be concatenated by using an expression of the form s3 = s1&s2;
A.1, 2, 5
B.2, 4
C.1, 3, 4
D.3, 5
Answer: Option C

96.Which of the following will be the correct output for the C#.NET code snippet given below?

String s1 = "Five Star";
String s2 = "FIVE STAR";
int c;
c = s1.CompareTo(s2);
Console.WriteLine(c);
A.0
B.1
C.2
D.-1
E.-2       
Answer: Option D

95.Which of the following statement is correct about a String in C#.NET?

A.A String is mutable because it can be modified once it has been created.
B.Methods of the String class can be used to modify the string.
C.A number CANNOT be represented in the form of a String.
D.A String has a zero-based index.
E.The System.Array class is used to represent a string.
Answer: Option D

94.Which of the following statements about a String is correct?

A.A String is created on the stack.
B.Whether a String is created on the stack or the heap depends on the length of the String.
C.A String is a primitive.
D.A String can be created by using the statement String s1 = new String;
E.A String is created on the heap.
Answer: Option E

93.Which of the following will be the correct output for the C#.NET code snippet given below?

String s1="Kicit";
Console.Write(s1.IndexOf('c') + " ");
Console.Write(si.Length);
A.3 6
B.2 5
C.3 5
D.2 6
E.3 7
Answer: Option B

92.What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
    class SampleProgram
    {
        static void Main(string[ ] args)
        {
            string str= "Hello World!";
            Console.WriteLine( String.Compare(str, "Hello World?" ).GetType() );
        }
    }
}
A.0
B.1
C.String
D.Hello World?
E.System.Int32
Answer: Option E

91.If s1 and s2 are references to two strings, then which of the following is the correct way to compare the two references?

A.s1 is s2
B.s1 = s2
C.s1 == s2
D.strcmp(s1, s2)
E.s1.Equals(s2)
Answer: Option E

90.Which of the following will be the correct output for the C#.NET code snippet given below?

String s1 = "Nagpur";
String s2;
s2 = s1.insert(6, "Mumbai");
Console.WriteLine(s2);
A.NagpuMumbair
B.Nagpur Mumbai
C.Mumbai
D.Nagpur
E.NagpurMumbai
Answer: Option E

89. Which of the following statements will correctly copy the contents of one string into another ?


88.Which of the following will be the correct output for the C#.NET code snippet given below?

String s1 = "ALL MEN ARE CREATED EQUAL";
String s2;
s2 = s1.Substring(12, 3);
Console.WriteLine(s2);
A.ARE
B.CRE
C.CR
D.REA
E.CREATED       
Answer: Option B

87.Which of the following statements are true about the C#.NET code snippet given below?

String s1, s2;
s1 = "Hi";
s2 = "Hi";
1.String objects cannot be created without using new.
2.Only one object will get created.
3.s1 and s2 both will refer to the same object.
4.Two objects will get created, one pointed to by s1 and another pointed to bys2.
5.s1 and s2 are references to the same object.
A.1, 2, 4
B.2, 3, 5
C.3, 4
D.2, 5
Answer: Option B

85.Which of the following is the correct way to implement a read only property Length in aSample class?

A.class Sample
{
    int len;
    public int Length
    {
        get
        {
            return len;
        }
    }
}
B.class Sample
{
    public int Length
    {
        get
        {
            return Length;
        }
    }
}
C.class Sample
{
    int len;
    public int Length
    {
        get
        {
            return len;
        }
        set
        {
            len = value;
        }
    }
}
D.class Sample
{
    int len;
    public int Length
    {
        Readonly get
        {
            return len;
        }
    }
}
Answer: Option A

84.Which of the following statements is correct about properties used in C#.NET?

A.Every property must have a set accessor and a get accessor.
B.Properties cannot be overloaded.
C.Properties of a class are actually methods that work like data members.
D.A property has to be either read only or a write only.
Answer: Option C

83.If Sample class has a Length property with get accessor then which of the following statements will work correctly?

A.Sample m = new Sample();
m.Length = 10;
B.Sample m = new Sample();
m.Length = m.Length + 20;
C.Sample m = new Sample();
int l;
l = m.Length;
D.Sample.Length = 20;
E.Console.WriteLine(Sample.Length);
Answer: Option C

82.If Sample class has a Length property with set accessor then which of the following statements will work correctly?

A.Sample m = new Sample();
int l;
l = m.Length;
B.    Sample m = new Sample();
m.Length = m.Length + 20;
C.    Sample.Length = 20;
D.    Console.WriteLine (Sample.Length);
E.    Sample m = new Sample();
m.Length = 10;
Answer: Option E

81. A property can be declared inside a namespace or a procedure.

A.True   
B.False
Answerca: Option B

80.If Sample class has a Length property with get and set accessors then which of the following statements will work correctly?p

1.Sample.Length = 20;
2.Sample m = new Sample();
3.m.Length = 10;
4.Console.WriteLine(Sample.Length);
5.Sample m = new Sample();
6.int len;
7.len = m.Length;
8.Sample m = new Sample();
9.m.Length = m.Length + 20;
A.1, 3
B.2, 4, 5
C.4 only
D.3, 5
Answer: Option B

79.Which of the following statements are correct?

1.The signature of an indexer consists of the number and types of its formal parameters.
2.Indexers are similar to properties except that their accessors take parameters.
3.Accessors of interface indexers use modifiers.
4.The type of an indexer and the type of its parameters must be at least as accessible as the indexer itself.
5.An interface accessor contains a body.
A.1, 3, 5
B.1, 2, 4
C.3, 5
D.2, 4
Answer: Option B

78.Which of the following statements is correct about properties used in C#.NET?

A.A property can simultaneously be read only or write only.
B.A property can be either read only or write only.
C.A write only property will have only get accessor.
D.A write only property will always return a value.
Answer: Option B

77.A property can be declared inside a class, struct, Interface.

A.True   
B.False
Answer: Option A

76.What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
    class SampleProgram
    {
        static void Main(string[ ] args)
        {
            int i = 5;
            int j;
            fun1(ref i);
            fun2(out j);
            Console.WriteLine(i + ", " + j);
        }
        static void funl(ref int x)
        {
            x = x * x;
        }
        static void fun2(out int x)
        {
            x = 6;
            x = x * x;
        }
    }
}
A.5, 6
B.5, 36
C.25, 36
D.25, 0
E.5, 0
Answer: Option C

75.A function can be used in an expression, whereas a subroutine cannot be.

A.True
B.False
Answer: Option A

74.Which of the following statements are correct about subroutines used in C#.NET?

1.If we do not return a value from a subroutine then a value -1 gets returned.
2.Subroutine definitions cannot be nested.
3.Subroutine can be called recursively.
4.To return the control from middle of a subroutine exit subroutine should be used.
5.Subroutine calls can be nested.
A.1, 2, 3
B.2, 3, 5
C.3, 5
D.3, 4
E.None of these
Answer: Option B

73. What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
    class SampleProgram
    {
        static void Main(string[ ] args)
        {
            int i;
            int res = fun(out i);
            Console.WriteLine(res);
        }
        static int fun (out int i)
        {
            int s = 1;
            i = 7;
            for(int j = 1; j <= i; j++)
            {
                s = s * j;
            }
            return s;
        }
    }
}
A.1
B.7
C.8
D.720
E.5040       
Answer: Option E

72.Which of the following CANNOT occur multiple number of times in a program?

A.namespace   
B.Entrypoint
C.Class   
D.Function
E.Subroutine       
Answer: Option B

71.How many values is a subroutine capable of returning?

A.Depends upon how many params arguments does it use.
B.Any number of values.
C.Depends upon how many ref arguments does it use.
D.0
E.1
Answer: Option D

70.What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
    class SampleProgram
    {
        static void Main(string[ ] args)
        {
            object[] o = new object[] {"1", 4.0, "India", 'B'};
            fun (o);
        }
        static void fun (params object[] obj)
        {
            for (int i = 0; i < obj.Length-1; i++)
            Console.Write(obj[i] + " ");
        }
    }
}
A.1 4.0 India B
B.1 4.0 India
C.1 4 India
D.1 India B
Answer: Option C

69.How many values is a function capable of returning?

A.1
B.0
C.Depends upon how many params arguments does it use.
D.Any number of values.
E.Depends upon how many ref arguments does it use.
Answer: Option A

68.Which of the following statements are correct about functions used in C#.NET?

1.Function definitions cannot be nested.
2.Functions can be called recursively.
3.If we do not return a value from a function then a value -1 gets returned.
4.To return the control from middle of a function exit function should be used.
5.Function calls can be nested.
A.1, 2, 5
B.2, 3, 5
C.2, 3
D.4, 5
E.None of these
Answer: Option A

67.Which of the following statements are correct?

1.C# allows a function to have arguments with default values.
2.C# allows a function to have variable number of arguments.
3.Omitting the return value type in method definition results into an exception.
4.Redefining a method parameter in the method's body causes an exception.
5.params is used to specify the syntax for a function with variable number of arguments.
A.1, 3, 5
B.3, 4, 5
C.2, 5
D.4, 5
E.None of these
Answer: Option C

66.What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
    class SampleProgram
    {
        static void Main(string[ ] args)
        {
            int i = 10;
            double d = 34.340;
            fun(i);
            fun(d);
        }
        static void fun(double d)
        {
            Console.WriteLine(d + " ");
        }
    }
}
A.10.000000 34.340000
B.10 34
C.10 34.340
D.10 34.34
Answer: Option D

65.Which of the following will be the correct output for the C#.NET program given below?

namespace IndiabixConsoleApplication
{
    class SampleProgram
    {
        static void Main(string[] args)
        {
            int a = 5;
            int s = 0, c = 0;
            Proc(a, ref s, ref c);
            Console.WriteLine(s + " " + c);
        }
        static void Proc(int x, ref int ss, ref int cc)
        {
            ss = x * x;
            cc = x * x * x;
        }
    }
}
A.0 0
B.25 25
C.125 125
D.25 125
E.None of the above
Answer: Option D

64.Which of the following statements are correct about functions and subroutines used in C#.NET?

1.A function cannot be called from a subroutine.
2.The ref keyword causes arguments to be passed by reference.
3.While using ref keyword any changes made to the parameter in the method will be reflected in that variable when control
passes back to the calling method.
4.A subroutine cannot be called from a function.
5.Functions and subroutines can be called recursively.
A.1, 2, 4
B.2, 3, 5
C.3, 5
D.4, 5
E.None of these
Answer: Option B

63.A function returns a value, whereas a subroutine cannot return a value.

A.True   
B.False
Answer: Option A

62. Which of the following statements are correct?

1.An argument passed to a ref parameter need not be initialized first.
2.Variables passed as out arguments need to be initialized prior to being passed.
3.Argument that uses params keyword must be the last argument of variable argument list of a method.
4.Pass by reference eliminates the overhead of copying large data items.
5.To use a ref parameter only the calling method must explicitly use the refkeyword.
A.1, 2
B.2, 3
C.3, 4
D.4, 5
E.None of these
Answer: Option C

61. What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
    class SampleProgram
    {
        static void Main(string[] args)
        {
            int[]arr = newint[]{ 1, 2, 3, 4, 5 };
            fun(ref arr);
        }
        static void fun(ref int[] a)
        {
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = a[i] * 5;
                Console.Write(a[ i ] + " ");
            }
        }
    }
}
A.1 2 3 4 5
B.6 7 8 9 10
C.5 10 15 20 25
D.5 25 125 625 3125
E.6 12 18 24 30
Answer: Option C

60.Which of the following will be the correct output for the C#.NET program given below?

namespace IndiabixConsoleApplication
{
    class SampleProgram
    {
        static void Main(string[] args)
        {
            int num = 1;
            funcv(num);
            Console.Write(num + ", ");
            funcr(ref num);
            Console.Write(num + ", ");
        }
        static void funcv(int num)
        {
            num = num + 10; Console.Write(num + ", ");
        }
        static void funcr (ref int num)
        {
            num = num + 10; Console.Write(num + ", ");
        }
    }
}
A.1, 1, 1, 1,
B.11, 1, 11, 11,
C.11, 11, 11, 11,
D.11, 11, 21, 11,
E.11, 11, 21, 21,
Answer: Option B

59.Which of the following statements is correct about constructors in C#.NET?

A.A constructor cannot be declared as private.
B.A constructor cannot be overloaded.
C.A constructor can be a static constructor.
D.A constructor cannot access static data.
E.this reference is never passed to a constructor.
Answer: Option C

58.What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
    class Sample
    {
        static Sample()
        {
            Console.WriteLine("Sample class");
        }
        public static void Bix1()
        {
            Console.WriteLine("Bix1 method");
        }
    }
    class MyProgram
    {
        static void Main(string[ ] args)
        {
            Sample.Bix1();
        }
    }
}
A.Sample class Bix1 method
B.Bix1 method
C.Sample class
D.Bix1 method Sample class
E.Sample class Sample class
Answer: Option A

57.Which of the following statements are correct about static functions?

A.Static functions are invoked using objects of a class.
B.Static functions can access static data as well as instance data.
C.Static functions are outside the class scope.
D.Static functions are invoked using class.
Answer: Option D

56.Is it possible for you to prevent an object from being created by using zero argument constructor?

A.Yes   
B.No
Answer: Option A

55.Which of the following statements is correct?

A.There is one garbage collector per program running in memory.
B.There is one common garbage collector for all programs.
C.An object is destroyed by the garbage collector when only one reference refers to it.
D.We have to specifically run the garbage collector after executing Visual Studio.NET.
Answer: Option B

54.Which of the following statements are correct about the C#.NET code snippet given below?

class Sample
{
    static int i;
    int j;
    public void proc1()
    {
        i = 11;
        j = 22;
    }
    public static void proc2()
    {
        i = 1;
        j = 2;
    }
    static Sample()
    {
        i = 0;
        j = 0;
    }
}
A.i cannot be initialized in proc1().
B.proc1() can initialize i as well as j.
C.j can be initialized in proc2().
D.The constructor can never be declared as static.
E.proc2() can initialize i as well as j.
Answer: Option B

53.Is it possible to invoke Garbage Collector explicitly?

A.Yes
B.No
Answer: Option A

52.How many times can a constructor be called during lifetime of the object?

A.As many times as we call it.
B.Only once.
C.Depends upon a Project Setting made in Visual Studio.NET.
D.Any number of times before the object gets garbage collected.
E.Any number of times before the object is deleted.
Answer: Option B

51.Which of the following statements are correct about constructors in C#.NET?

1.Constructors cannot be overloaded.
2.Constructors always have the name same as the name of the class.
3.Constructors are never called explicitly.
4.Constructors never return any value.
5.Constructors allocate space for the object in memory.
A.1, 3, 5
B.2, 3, 4
C.3, 5
D.4, 5
E.None of these
Answer: Option B

50.Can static procedures access instance data?

A.Yes   
B.No
Answer: Option B

49.In which of the following should the methods of a class differ if they are to be treated as overloaded methods?

1.Type of arguments
2.Return type of methods
3.Number of arguments
4.Names of methods
5.Order of arguments
A.2, 4
B.3, 5
C.1, 3, 5
D.3, 4, 5
Answer: Option C

48.Which of the following statements is correct about constructors?

A.If we provide a one-argument constructor then the compiler still provides a zero-argument constructor.
B.Overloaded constructors have the same name as the class name.
C.Overloaded constructors cannot use optional arguments.
D.If we do not provide a constructor, then the compiler provides a zero-argument constructor.
E.Static constructors can use optional arguments.
Answer: Option D

47.Which of the following statements are correct about static functions?

1.Static functions can access only static data.
2.Static functions cannot call instance functions.
3.It is necessary to initialize static data.
4.Instance functions can call static functions and access static data.
5.this reference is passed to static functions.
A.1, 2, 4
B.2, 3, 5
C.3, 4
D.4, 5
E.None of these
Answer: Option A

46. Which of the following ways to create an object of the Sample class given below will work correctly?

class Sample
{
    int i;
    Single j;
    double k;
    public Sample (int ii, Single jj, double kk)
    {
        i = ii;
        j = jj;
        k = kk;
    }
}
A.Sample s1 = new Sample();
B.Sample s1 = new Sample(10);
C.Sample s2 = new Sample(10, 1.2f);
D.Sample s3 = new Sample(10, 1.2f, 2.4);
E.Sample s1 = new Sample(, , 2.5);
Answer: Option D

45.Which of the following statements is correct about the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
    class Sample
    {
        public int func()
        {
            return 1;
        }
        public Single func()
        {
            return 2.4f ;
        }
    }
    class Program
    {
        static void Main(string[ ] args)
        {
            Sample s1 = new Sample();
            int i;
            i = s1.func();
            Single j;
            j = s1.func();
        }
    }
}
A.func() is a valid overloaded function.
B.Overloading works only in case of subroutines and not in case of functions.
C.func() cannot be considered overloaded because: return value cannot be used to distinguish between two overloaded functions.
D.The call to i = s1.func() will assign 1 to i.
E.The call j = s1.func() will assign 2.4 to j.
Answer: Option C

44.Which of the following statements is correct?

A.A constructor can be used to set default values and limit instantiation.
B.C# provides a copy constructor.
C.Destructors are used with classes as well as structures.
D.A class can have more than one destructor.
Answer: Option A

43.Which of the following statements are correct about the Collection Classes available in Framework Class Library?

A.Elements of a collection cannot be transmitted over a network.
B.Elements stored in a collection can be retrieved but cannot be modified.
C.It is not easy to adopt the existing Collection classes for newtype of objects.
D.Elements stored in a collection can be modified only if allelements are of similar types.
E.They use efficient algorithms to manage the collection, thereby improving the performance of the program.
Answer: Option E

42.Which of the following is the correct way to find out the number of elements currently present in an ArrayList Collection called arr?

A.arr.Count
B.arr.GrowSize
C.arr.MaxIndex
D.arr.Capacity
E.arr.UpperBound
Answer: Option A

41.Which of the following is an ordered collection class?

1.Map
2.Stack
3.Queue
4.BitArray
5.HashTable
A.1 only
B.2 and 3 only
C.4 and 5 only
D.All of the above
E.None of the above
Answer: Option B

40.Which of the following is NOT an interface declared in System.Collectionsnamespace?

A.IComparer
B.Enumerable
C.Enumerator
D.IDictionaryComparer
E.IDictionaryEnumerator
Answer: Option D

39.Which of the following statements are correct about the Stack collection?

1.It can be used for evaluation of expressions.
2.All elements in the Stack collection can be accessed using an enumerator.
3.It is used to maintain a FIFO list.
4.All elements stored in a Stack collection must be of similar type.
5.Top-most element of the Stack collection can be accessed using the Peek()method.
A.1 and 2 only
B.3 and 4 only
C.1, 2 and 5 only
D.All of the above
E.None of the above
Answer: Option C

38.Which of the following statements are correct about the C#.NET code snippet given below?

Stack st = new Stack();
st.Push("hello");
st.Push(8.2);
st.Push(5);
st.Push('b');
st.Push(true);
A.Dissimilar elements like "hello", 8.2, 5 cannot be stored in the sameStack collection.
B.Boolean values can never be stored in Stack collection.
C.In the fourth call to Push(), we should write "b" in place of 'b'.
D.To store dissimilar elements in a Stack collection, a method PushAnyType()should be used in place of Push().
E.This is a perfectly workable code.
Answer: Option E

37. In a HashTable Key cannot be null, but Value can be?

A.True   
B.False
Answer: Option A

36.In which of the following collections is the Input/Output based on a key?

1.Map
2.Stack
3.BitArray
4.HashTable
5.SortedList
A.1 and 2 only
B.2 and 3 only
C.1, 2 and 3 only
D.4 and 5 only
E.All of the above
Answer: Option D

35. In which of the following collections is the Input/Output index-based?

1.Stack
2.Queue
3.BitArray
4.ArrayList
5.HashTable
A.1 and 2 only
B.3 and 4 only
C.5 only
D.1, 2 and 5 only
E.All of the above
Answer: Option B

34.How many enumerators will exist if four threads are simultaneously working on anArrayList object?

A.1
B.3
C.2
D.4
Answer: Option D

33.Which of the following statements are correct about an ArrayList collection that implements the IEnumerable interface?

1.The ArrayList class contains an inner class that implements theIEnumerator interface.
2.An ArrayList Collection cannot be accessed simultaneously by different threads.
3.The inner class of ArrayList can access ArrayList class's members.
4.To access members of ArrayList from the inner class, it is necessary to pass ArrayList class's reference to it.
5.Enumerator's of ArrayList Collection can manipulate the array.
A.1 and 2 only
B.1 and 3 and 4 only
C.2 and 5 only
D.All of the above
E.None of the above
Answer: Option B

32.What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
    class SampleProgram
    {
        static void Main(string[ ] args)
        {
            int i, j;
            int[ , ] arr = new int[ 2, 2 ];
            for(i = 0; i < 2; ++i)
            {
                for(j = 0; j < 2; ++j)
                {
                    arr[i, j] = i * 17 + i * 17;
                    Console.Write(arr[ i, j ] + " ");
                }
            }
        }
    }
}
A.0 0 34 34
B.0 0 17 17
C.0 0 0 0
D.17 17 0 0
E.34 34 0 0
Answer: Option A

31.Which of the following is the correct way to obtain the number of elements present in the array given below?

int[] intMyArr = {25, 30, 45, 15, 60};
1.intMyArr.GetMax;
2.intMyArr.Highest(0);
3.intMyArr.GetUpperBound(0);
4.intMyArr.Length;
5.intMyArr.GetMaxElements(0);
A.1, 2
B.3, 4
C.3, 5
D.1, 5
E.4, 5
Answer: Option B

30.Which of the following is the correct output of the C#.NET code snippet given below?

int[][] a = new int[2][];
    a[0] = n ew int[4]{6, 1, 4, 3};
    a[1] = new int[3]{9, 2, 7};
    Console.WriteLine(a[1].GetUpperBound(0));
A.3   
B.4
C.7
D.9
E.2       
Answer: Option E

29.Which of the following is the correct way to define and initialise an array of 4 integers?

1.int[] a = {25, 30, 40, 5};
2.int[] a;
3.a = new int[3];
4.a[0] = 25;
5.a[1] = 30;
6.a[2] = 40;
7.a[3] = 5;
8.int[] a;
9.a = new int{25, 30, 40, 5};
10.int[] a;
11.a = new int[4]{25, 30, 40, 5};
12.int[] a;
13.a = new int[4];
14.a[0] = 25;
15.a[1] = 30;
16.a[2] = 40;
17.a[3] = 5;
A.1, 2
B.3, 4
C.1, 4, 5
D.2, 4, 5
E.5, 5
Answer: Option C

28.Which of the following statements is correct about the C#.NET code snippet given below?

int[] intMyArr = {11, 3, 5, 9, 4};
A.intMyArr is a reference to an object of System.Array Class.
B.intMyArr is a reference to an object of a class that the compiler derives fromSystem.Array Class.
C.intMyArr is a reference to an array of integers.
D.intMyArr is a reference to an object created on the stack.
E.intMyArr is a reference to the array created on the stack.
Answer: Option B

27.Which of the following statements is correct about the array declaration given below?

int[][][] intMyArr = new int[2][][];
A.intMyArr refers to a 2-D jagged array containing 2 rows.
B.intMyArr refers to a 2-D jagged array containing 3 rows.
C.intMyArr refers to a 3-D jagged array containing 2 2-D jagged arrays.
D.intMyArr refers to a 3-D jagged array containing three 2-D jagged arrays.
E.intMyArr refers to a 3-D jagged array containing 2 2-D rectangular arrays.
Answer: Option C

26.Which of the following are the correct ways to define an array of 2 rows and 3 columns?

1.int[ , ] a;
2.a = new int[2, 3]{{7, 1, 3},{2, 9, 6}};
3.int[ , ] a;
4.a = new int[2, 3]{};
5.int[ , ] a = {{7, 1, 3}, {2, 9,6 }};
6.int[ , ] a;
7.a = new int[1, 2];
8.int[ , ] a;
9.a = new int[1, 2]{{7, 1, 3}, {2, 9, 6}};
A.1, 2 , 3
B.1, 3
C.2, 3
D.2, 4, 5
E.4, 5
Answer: Option B

25.Which of the following statements are correct about the C#.NET code snippet given below?

int[][]intMyArr = new int[2][];
   intMyArr[0] = new int[4]{6, 1, 4, 3};
   intMyArr[1] = new int[3]{9, 2, 7};
A.intMyArr is a reference to a 2-D jagged array.
B.The two rows of the jagged array intMyArr are stored in adjacent memory locations.
C.intMyArr[0] refers to the zeroth 1-D array and intMyArr[1] refers to the first 1-D array.
D.intMyArr refers to intMyArr[0] and intMyArr[1].
E.intMyArr refers to intMyArr[1] and intMyArr[2].
Answer: Option C

24.Which of the following statements are correct about arrays used in C#.NET?

1.Arrays can be rectangular or jagged.
2.Rectangular arrays have similar rows stored in adjacent memory locations.
3.Jagged arrays do not have an access to the methods of System.ArrayClass.
4.Rectangular arrays do not have an access to the methods of System.ArrayClass.
5.Jagged arrays have dissimilar rows stored in non-adjacent memory locations.
A.1, 2
B.1, 3, 5
C.3, 4
D.1, 2, 5
E.4, 5
Answer: Option D

23.Creating empty structures is allowed in C#.NET?

A.True   
B.False
Answer: Option B

21.How will you complete the foreach loop in the C#.NET code snippet given below such that it correctly prints all elements of the array a?

int[][]a = new int[2][];
    a[0] = new int[4]{6, 1 ,4, 3};
    a[1] = new int[3]{9, 2, 7};
    foreach (int[ ] i in a)
    {
        /* Add loop here */
        Console.Write(j + " ");
        Console.WriteLine();
    }
A.foreach (int j = 1; j < a(0).GetUpperBound; j++)
B.foreach (int j = 1; j < a.GetUpperBound (0); j++)
C.foreach (int j in a.Length)
D.foreach (int j in i)
E.foreach (int j in a.Length -1)
Answer: Option D

22.Which of the following is the correct output of the C#.NET code snippet given below?

int[ , , ] a = new int[ 3, 2, 3 ];
Console.WriteLine(a.Length);
A.20   
B.4
C.18
D.10
E.5       
Answer: Option C

20. If a is an array of 5 integers then which of the following is the correct way to increase its size to 10 elements?20.If a is an array of 5 integers then which of the following is the correct way to increase its size to 10 elements?

A. int[] a = new int[5];
    int[] a = new int[10];
B. int[] a = int[5];
    int[] a = int[10];
C. int[] a = new int[5];
    a.Length = 10 ;
D. int[] a = new int[5];
    a = new int[10];
E. int[] a = new int[5];
   a.GetUpperBound(10);
Answer: Option D

19. Which one of the following statements is correct?

A. Array elements can be of integer type only.
B. The rank of an Array is the total number of elements it can contain.
C. The length of an Array is the number of dimensions in the Array.
D. The default value of numeric array elements is zero.
E. The Array elements are guaranteed to be sorted.
Answer: Option D

18.Which of the following statements are correct about the C#.NET code snippet given below?

 int[] a = {11, 3, 5, 9, 4};
1.The array elements are created on the stack.
2.Refernce a is created on the stack.
3.The array elements are created on the heap.
4.On declaring the array a new array class is created which is derived fromSystem.Array Class.
5.Whether the array elements are stored in the stack or heap depends upon the size of the array.
A. 1, 2
B. 2, 3, 4
C. 2, 3, 5
D. 4, 5
E. None of these
Answer: Option B

17. Which of the following statements are correct about the C#.NET code snippet given below?

int[ , ] intMyArr = {{7, 1, 3}, {2, 9, 6}};
1.intMyArr represents rectangular array of 2 rows and 3 columns.
2.intMyArr.GetUpperBound(1) will yield 2.
3.intMyArr.Length will yield 24.
4.intMyArr represents 1-D array of 5 integers.
5.intMyArr.GetUpperBound(0) will yield 2.
A. 1, 2
B. 2, 3
C. 2, 5
D. 1, 4
E.  3, 4
Answer: Option A

16. Which of the following statements is correct about classes and objects in C#.NET?

A. Class is a value type.
B. Since objects are typically big in size, they are created on the stack.
C. Objects of smaller size are created on the heap.
D. Smaller objects that get created on the stack can be given names.
E. Objects are always nameless.
Answer: Option E

15. Which of the following statements are correct about the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
    class Sample
    {
        int i, j;
        public void SetData(int ii, int jj)
        {
            this.i = ii;
            this.j = jj
        }
    }
    class MyProgram
    {
        static void Main(string[ ] args)
        {
            Sample s1 = new Sample();
            s1.SetData(10, 2);
            Sample s2 = new Sample();
            s2.SetData(5, 10);
        }
    }
}
A.The code will not compile since we cannot explicitly use this.
B.Using this in this program is necessary to properly set the values in the object.
C.The call to SetData() is wrong since we have not explicitly passed the thisreference to it.
D.The definition of SetData() is wrong since we have not explicitly collected the this reference.
E.Contents of this will be different during each call to SetData().
Answer: Option E

0 comments:

Post a Comment