C# and Java Programming Fundamentals
Test your knowledge of C# and Java programming concepts including OOP, inheritance, constructors, exception handling, and memory management
Questions
A garbage collected object can be reached again.
- True
- False
true and false are keywords in JAVA
- True
- False
The java.lang package is always imported by default.
- True
- False
A transient variable may be serialized.
- True
- False
If a class has a Static Constructor and a Public Constructor,Which one is invoked first upon object initialization?
- public constructor
- static constructor
- both
- I don't know.
What’s the .NET datatype that allows the retrieval of data by a unique key?
- NamedValueCollection
- HashTable
- SortedList
- I don't know
Can Abstarct class have a constructor?
- Yes, Only Concrete constructor
- Yes, Only Abstract constructor.
- No
- I don't know.
Are private class-level variables inherited?
- No, and they are not accessible
- Yes, but they are not accessible
- May be
- I don't know.
Which of the following statements correctly declares a 2 dimensional array in c#?
- int[,] myarray;
- int[][] myarray;
- int myarray[,];
- int[2] myarray;
For the C# Compiler (csc.exe), which option is the default output type among the given Output options ?
- /target:library
- /target:module
- /target:exe
- /target:winexe
How can we prevent a class from Instantiating?
- Use Abstract class
- Use Private Constructor
- Both of the above
- Use Sealed class
What is the difference between the S.ToString() and Convert.ToString(S) in the given scenario?
- No difference
- S.ToString() handles null values
- Convert.ToString(S) handles null values
- I don't know.
Can we invoke the garbage collector explicitly?
- Yes, but the actual collection is not deterministic
- No.
- Yes, and the actual collection is deterministic
- I don't know.
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?
- Yes
- No
- May be
- I don't know
Which of the following signifies implementation inheritance?
- Public Inheritance
- Protected Inheritance
- Private Inheritance
- Virtual Inheritance
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; }
- 20,10
- 10,20
- 1,10
- 20,2
static keyword can be used with virtual functions.
- True
- False
Which of the following describes the correct syntax for overloading new operator for arrays
- new operator cannot be overloaded
- void *operator new(size_t,int);
- void operator new;
- void *operator new;
Which of the following operators cannot be overloaded?
- ~
- .*
- &
- ->*
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{};
- nothing wrong will complie fine.
- class cannot inherit from struct
- struct cannot inherit from class
- struct cannot have constructor