C# and Java Programming Fundamentals

Test your knowledge of C# and Java programming concepts including OOP, inheritance, constructors, exception handling, and memory management

20 Questions Published

Questions

Question 1 True/False

A garbage collected object can be reached again.

  1. True
  2. False
Question 2 True/False

true and false are keywords in JAVA

  1. True
  2. False
Question 3 True/False

The java.lang package is always imported by default.

  1. True
  2. False
Question 4 True/False

A transient variable may be serialized.

  1. True
  2. False
Question 5 Multiple Choice (Single Answer)

If a class has a Static Constructor and a Public Constructor,Which one is invoked first upon object initialization?

  1. public constructor
  2. static constructor
  3. both
  4. I don't know.
Question 6 Multiple Choice (Single Answer)

What’s the .NET datatype that allows the retrieval of data by a unique key?

  1. NamedValueCollection
  2. HashTable
  3. SortedList
  4. I don't know
Question 7 Multiple Choice (Single Answer)

Can Abstarct class have a constructor?

  1. Yes, Only Concrete constructor
  2. Yes, Only Abstract constructor.
  3. No
  4. I don't know.
Question 8 Multiple Choice (Single Answer)

Are private class-level variables inherited?

  1. No, and they are not accessible
  2. Yes, but they are not accessible
  3. May be
  4. I don't know.
Question 9 Multiple Choice (Single Answer)

Which of the following statements correctly declares a 2 dimensional array in c#?

  1. int[,] myarray;
  2. int[][] myarray;
  3. int myarray[,];
  4. int[2] myarray;
Question 10 Multiple Choice (Single Answer)

For the C# Compiler (csc.exe), which option is the default output type among the given Output options ?

  1. /target:library
  2. /target:module
  3. /target:exe
  4. /target:winexe
Question 11 Multiple Choice (Single Answer)

How can we prevent a class from Instantiating?

  1. Use Abstract class
  2. Use Private Constructor
  3. Both of the above
  4. Use Sealed class
Question 12 Multiple Choice (Single Answer)

What is the difference between the S.ToString() and Convert.ToString(S) in the given scenario?

  1. No difference
  2. S.ToString() handles null values
  3. Convert.ToString(S) handles null values
  4. I don't know.
Question 13 Multiple Choice (Single Answer)

Can we invoke the garbage collector explicitly?

  1. Yes, but the actual collection is not deterministic
  2. No.
  3. Yes, and the actual collection is deterministic
  4. I don't know.
Question 14 Multiple Choice (Single Answer)

In the above code, the call to the factorial() throws StackOverflowException. Will the finally block gets executed and prints the "finally" message to the user?

  1. Yes
  2. No
  3. May be
  4. I don't know
Question 15 Multiple Choice (Single Answer)

Which of the following signifies implementation inheritance?

  1. Public Inheritance
  2. Protected Inheritance
  3. Private Inheritance
  4. Virtual Inheritance
Question 16 Multiple Choice (Single Answer)

What will be the output of the following code: main() { int a=10,b=20; a=a^b; b=a^b; a=a^b; cout<<a<<","<<b; }

  1. 20,10
  2. 10,20
  3. 1,10
  4. 20,2
Question 17 True/False

static keyword can be used with virtual functions.

  1. True
  2. False
Question 18 Multiple Choice (Single Answer)

Which of the following describes the correct syntax for overloading new operator for arrays

  1. new operator cannot be overloaded
  2. void *operator new(size_t,int);
  3. void operator new;
  4. void *operator new;
Question 19 Multiple Choice (Single Answer)

Which of the following operators cannot be overloaded?

  1. ~
  2. .*
  3. &
  4. ->*
Question 20 Multiple Choice (Single Answer)

What is the problem,if any in the following code: struct Sample { int a; Sample() { a=0; } }; class Sample2:public Sample { }; struct Sample3:protected Sample2{};

  1. nothing wrong will complie fine.
  2. class cannot inherit from struct
  3. struct cannot inherit from class
  4. struct cannot have constructor