C# and Java Programming Concepts
Test your knowledge of C# and Java programming fundamentals including generics, delegates, structures, value/reference types, interfaces, exceptions, threading, and string handling.
Questions
Is sizeof a keyword?
- True
- False
Static method accecss non-static field or call non-static method (T/F)
- True
- False
What methods java providing for Thread communications
- Wait
- notify
- notifyAll
- Sleep
IOexception is a unchecked exception (T/F)
- True
- False
These classes are defined in separate files. Will this code compile successfully? package dir1; class Parent { public java.util.Set set; } package dir2; class Child extends dir1.Parent { void test() { set.add("Hello"); } }
- True
- False
For concatenation of strings, which method is good, StringBuffer or String
- String
- StringBuffer
- Both
- None
For concatenation of strings, which method is good, StringBuffer or String
- String Buffer
- String
- both
- none
The following are used for Thread communication
- wait,notify,notifyall
- wait,notify,notifyall,sleep
- Yield,sleep
- yield, sleep, wait
Java provide ______ construct to find out the size of an object
- sizeOf ()
- size()
- getSize()
- No such method in java to find size of an object directly.
modifiers that allowed for methods in an Interface
- public, abstract
- abstract, final
- final
- public
What is "delete" in java?
- a Keyword
- a method
- a special identifier
- none
Differences between Value types and Reference types
- Value type variables are stored on stack. Reference type variables are stored on heap.
- Value type holds the data directly, Reference type points to the location that holds the data.
- Value type cannot contain null value. Reference type can contain null value.
- A new type cannot be derived from value type. A new type can be derived from reference type.
- All of the above
Which of the following is value type
- string
- class
- delegate
- struct
- interface
what is the difference between indexer and property
- An indexer is always an instance member, but a property can be static also.
- A property is always an instance member, but An indexer can be static also.
- Indexers can not be participate in inheritance, properties can also participate in inheritance
- No difference
Abstract methods should override in non abstract child class. If the child class is also abstract class then abstract methods overriding is not mandatory.
- True
- False
Structure
- Structures can be used as a base for other structures.
- A structure can implement one or more interfaces.
- Structure members can be methods, fields, indexers, properties, operator methods, and events.
- Structures can also define constructors, but not destructors. And you cannot define a default (parameterless) constructor for a structure.
Generic Constraints
- Can not use in structs
- A derivation constraint
- A default constructor constraint
- A reference/value type constraint
C# allows you to define static methods that use generic type parameters
- True
- False
A delegate defined in a class can take advantage of the generic type parameter of that class
- True
- False
.NET allows you to have serializable generic types
- True
- False