Curioustab
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Constructors Questions
C#.NET — Trace static vs instance calls and method overloading to predict console output. Program: namespace CuriousTabConsoleApplication { class Sample { public static void fun1() { Console.WriteLine("CuriousTab1 method"); } public void fun2() { fun1(); Console.WriteLine("CuriousTab2 method"); } public void fun2(int i) { Console.WriteLine(i); fun2(); } } class MyProgram { static void Main(string[] args) { Sample s = new Sample(); Sample.fun1(); s.fun2(123); } } } What will be printed in order?
C#.NET — Static constructor vs static method: determine the order of outputs. Program: namespace CuriousTabConsoleApplication { class Sample { static Sample() { Console.Write("Sample class "); } public static void CuriousTab1() { Console.Write("CuriousTab1 method "); } } class MyProgram { static void Main(string[] args) { Sample.CuriousTab1(); } } } What will be printed?
C#.NET — Can you prevent outside code from creating an instance by using (or controlling) the parameterless constructor? Give the precise rule used in C# object-oriented design.
C#.NET constructors — Choose the correct definitions so that both of the following lines compile and create objects: Sample s1 = new Sample(); Sample s2 = new Sample(9, 5.6f);
C#.NET — For the class below, which object-creation statements will compile? class Sample { int i; Single j; double k; public Sample(int ii, Single jj, double kk) { i = ii; j = jj; k = kk; } }
C#.NET — Which statement about constructors is correct?
C#.NET — Is it possible to explicitly invoke the Garbage Collector (GC)?
C#.NET — For methods to be considered overloaded, which aspects must differ? (Select the correct set.) Consider: Type of arguments; Return type of methods; Number of arguments; Names of methods; Order of arguments.
C#.NET — Which statements about static methods are correct?
C#.NET — Analyze static vs instance access in the following code and select the correct statement(s): 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; } }
C#.NET — Which statement is correct regarding constructors and destructors?
C#.NET overloading — What is wrong with the following code and which statement is correct? namespace CuriousTabConsoleApplication { 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(); } } }
C#.NET — Which statement about constructors is correct?
C#.NET — Can a static method access instance data directly?
C#.NET — During the lifetime of a single object, how many times can its constructor run?
C#.NET — Identify the correct statements about constructors:
C#.NET — Which statement about the garbage collector (GC) is correct?
C#.NET — Which statements about static methods are correct?