Deck 2: C Programming: Data Types, Constructors, Inheritance, and Exception Handling
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/40
Play
Full screen (f)
Deck 2: C Programming: Data Types, Constructors, Inheritance, and Exception Handling
1
Which of the following statements are correct about data types?1. If the integer literal exceeds the range of byte, a compilation error will occur.2. We cannot implicitly convert non-literal numeric types of larger storage size to byte.3. Byte cannot be implicitly converted to float.4. A char can be implicitly converted to only int data type. 5. We can cast the integral character codes.
A)1,3,5
B)2,4
C)3,5
D)1,2,5
A)1,3,5
B)2,4
C)3,5
D)1,2,5
1,2,5
2
Which of the following is NOT an Integer?
A)Char
B)Byte
C)Integer
D)Long
A)Char
B)Byte
C)Integer
D)Long
Char
3
What will be the output of the following code snippet when it is executed?int x = 1;float y = 1.1f;short z = 1;Console.Write.Line((float) x + y * z - (x += (short) y));
A)0.1
B)1.0
C)1.1
D)11
A)0.1
B)1.0
C)1.1
D)11
0.1
4
Which of the following is the correct size of a Decimal datatype?
A)8 bytes
B)4 bytes
C)10 bytes
D)None of the above
A)8 bytes
B)4 bytes
C)10 bytes
D)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
5
Which of the following statements are correct?1. We can assign values of any type to variables of type object.2. When a variable of a value type is converted to object, it is said to be unboxed.3. When a variable of type object is converted to a value type, it is said to be boxed.4. Boolean variable cannot have a value of null.5. When a value type is boxed, an entirely new object must be allocated and constructed.
A)2,5
B)1,5
C)3,4
D)2,3
A)2,5
B)1,5
C)3,4
D)2,3
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
6
Which of the following is the correct ways to set a value 3.14 in a variable pi such that it cannot be modified?
A)float pi = 3.14F;
B)#define pi 3.14F;
C)const float pi = 3.14F;
D)const float pi; pi = 3.14F;
A)float pi = 3.14F;
B)#define pi 3.14F;
C)const float pi = 3.14F;
D)const float pi; pi = 3.14F;
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
7
Which of the following can be used to terminate a while loop and transfer control outside the loop?1. exit while2. continue3. exit statement4. break5. goto
A)1,3
B)2,4
C)3,5
D)4,5
A)1,3
B)2,4
C)3,5
D)4,5
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
8
Which of the following statements are correct about the C#.NETcode snippet given below?if (age > 18 && no < 11) a = 25;1. The condition no < 11 will be evaluated only if age > 18 evaluates to True.2. The statement a = 25 will get executed if any one condition is True.3. The condition no < 11 will be evaluated only if age > 18 evaluates to False.4. The statement a = 25 will get executed if both the conditions are True.5. && is known as a short circuiting logical operator.
A)1,3
B)2,5
C)1,4,5,
D)3,4,5
A)1,3
B)2,5
C)1,4,5,
D)3,4,5
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
9
Which of the following is the correct output for the C#.NET code snippet given below? Console.WriteLine(13 / 2 + " " + 13 % 2);
A)6.5 1
B)6.5 0
C)6 0
D)6 1
A)6.5 1
B)6.5 0
C)6 0
D)6 1
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
10
Which of the following statements are correct?1. Instance members of a class can be accessed only through an object of that class.2. A class can contain only instance data and instance member function.3. All objects created from a class will occupy equal number of bytes in memory.4. A class can contain Friend functions.5. A class is a blueprint or a template according to which objects are created.
A)1,3,5
B)2,4
C)3,5
D)2,4,5
A)1,3,5
B)2,4
C)3,5
D)2,4,5
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
11
Which of the following is the correct way to create an object of the class Sample?1. Sample s = new Sample();2. Sample s;3. Sample s; s = new Sample();4. s = new Sample();
A)1,3
B)2,4
C)1,2,3
D)4,5
A)1,3
B)2,4
C)1,2,3
D)4,5
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
12
Which of the following statements is correct about constructors?
A)If we provide a one-argument constructor then the compiler still provides a zeroargument 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.
A)If we provide a one-argument constructor then the compiler still provides a zeroargument 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.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
13
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.
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.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
14
Which of the following can be facilitated by the Inheritance mechanism?1. Use the existing functionality of base class.2. Overrride the existing functionality of base class.3. Implement new functionality in the derived class.4. Implement polymorphic behaviour.5. Implement containership.
A)1,2,3
B)3,4
C)2,4,5
D)3,5
A)1,2,3
B)3,4
C)2,4,5
D)3,5
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
15
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.
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.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
16
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.Array Class.4. Rectangular arrays do not have an access to the methods of System.Array Class.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
A)1,2
B)1,3,5
C)3,4
D)1,2,5
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
17
Which of the following statements are correct?1. A struct can contain properties.2. A struct can contain constructors.3. A struct can contain protected data members.4. A struct cannot contain methods.5. A struct cannot contain constants.
A)1,2
B)3,4
C)1,2,4
D)3,5
A)1,2
B)3,4
C)1,2,4
D)3,5
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
18
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
A)ARE
B)CRE
C)CR
D)REA
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
19
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)s1.Equals(s2)
A)s1 is s2
B)s1=s2
C)s1==s2
D)s1.Equals(s2)
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
20
Which of the following statements is correct about an Exception?
A)It occurs during compilation.
B)It occurs during linking.
C)It occurs at run-time.
D)It occurs during Just-In-Time compilation.
A)It occurs during compilation.
B)It occurs during linking.
C)It occurs at run-time.
D)It occurs during Just-In-Time compilation.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
21
Which of the following statements are correct about exception handling in C#.NET?1 If an exception occurs then the program terminates abruptly without getting any chance to recover from the exception. 2 No matter whether an exception occurs or not, the statements in the finally clause (if present) will get executed.3 A program can contain multiple finally clauses.4 A finally clause is written outside the try block.5 Finally clause is used to perform cleanup operations like closing the network/database connections.
A)1 only
B)2 only
C)2 and 5 only
D)3 and 4 only
A)1 only
B)2 only
C)2 and 5 only
D)3 and 4 only
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
22
______ parameters are used to pass results back to the calling method.
A)Input
B)Reference
C)Value
D)Output
A)Input
B)Reference
C)Value
D)Output
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
23
The formal-parameter-list is always enclosed in _______.
A)Square
B)Semicolon
C)Parenthesis
D)Colon
A)Square
B)Semicolon
C)Parenthesis
D)Colon
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
24
_______ variables are visible only in the block they are declared.
A)System
B)Global
C)Local
D)Console
A)System
B)Global
C)Local
D)Console
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
25
C# does not support _____ constructors.
A)parameterized
B)parameter-less
C)Class
D)Method
A)parameterized
B)parameter-less
C)Class
D)Method
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
26
A structure in C# provides a unique way of packing together data of ______ types.
A)Different
B)Same
C)Invoking
D)Calling
A)Different
B)Same
C)Invoking
D)Calling
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
27
Struct's data members are ____________ by default.
A)Protected
B)Public
C)Private
D)Default
A)Protected
B)Public
C)Private
D)Default
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
28
A _______ creates an object by copying variables from another object.
A)Copy constructor
B)Default constructor
C)Invoking constructor
D)Calling constructor
A)Copy constructor
B)Default constructor
C)Invoking constructor
D)Calling constructor
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
29
The methods that have the same name, but different parameter lists and different definitions is called______.
A)Method Overloading
B)Method Overriding
C)Method Overwriting
D)Method Overreading
A)Method Overloading
B)Method Overriding
C)Method Overwriting
D)Method Overreading
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
30
The C# provides special methods known as _____ methods to provide access to data members.
A)Loop
B)Functions
C)Methods
D)Accessor
A)Loop
B)Functions
C)Methods
D)Accessor
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
31
Storage location used by computer memory to store data for usage by an application is ?
A)Pointers
B)Constants
C)Variable
D)None of the mentioned
A)Pointers
B)Constants
C)Variable
D)None of the mentioned
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
32
Which of these can be overloaded?
A)Constructors
B)Methods
C)Both a & b
D)None of the mentioned
A)Constructors
B)Methods
C)Both a & b
D)None of the mentioned
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
33
Number of constructors a class can define of ?
A)1
B)2
C)Any number
D)None of the mentioned
A)1
B)2
C)Any number
D)None of the mentioned
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
34
Correct statement about constructors in C#.NET is ?
A)Constructor cannot be overloaded
B)Constructor allocate space for object in memory
C)Constructor are never called explicitly
D)Constructor have same name as name of the class
A)Constructor cannot be overloaded
B)Constructor allocate space for object in memory
C)Constructor are never called explicitly
D)Constructor have same name as name of the class
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
35
Constructors are used to
A)initialize the objects
B)construct the data members
C)both a & b
D)None of the mentioned
A)initialize the objects
B)construct the data members
C)both a & b
D)None of the mentioned
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
36
To overload a method which of the following statement is false?
A)If the return type is different methods are overloaded
B)Name of the overloaded method should be same
C)Type of the parameter should be different
D)Order of the parameter should be different if types are same
A)If the return type is different methods are overloaded
B)Name of the overloaded method should be same
C)Type of the parameter should be different
D)Order of the parameter should be different if types are same
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
37
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)None of the mentioned
A)A constructor cannot be declared as private
B)A constructor cannot be overloaded
C)A constructor can be a static constructor
D)None of the mentioned
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
38
What is return type of constructors?
A)int
B)float
C)void
D)None of the mentioned
A)int
B)float
C)void
D)None of the mentioned
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
39
Which method have same name as that of its class?
A)delete
B)class
C)constructor
D)None of mentioned
A)delete
B)class
C)constructor
D)None of mentioned
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
40
Which of following statement are correct about functions?
A)C# allows a function to have arguments with default values
B)Redefining a method parameter in the method's body causes an exception
C)C# allows function to have arguments of private type
D)Omitting the return type in method definition results into exception
A)C# allows a function to have arguments with default values
B)Redefining a method parameter in the method's body causes an exception
C)C# allows function to have arguments of private type
D)Omitting the return type in method definition results into exception
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck