Programming Languages: Java, C#, C, and C++ Concepts
Test your knowledge of programming language concepts including LINQ in C#, operator precedence in C, string/integer comparison in Java, and C++ namespace and rvalue rules.
Questions
A function call is always an rvalue. True or false?
- True
- False
In namespace foo, the function bar can access the variable x also declared in namespace foo? #include namespace foo { void bar() { x++; } int x; } int main(int argc, char** argv) { return 0; }
- True
- False
What is the value of y at the end of main? const int x = 5; int main(int argc, char** argv) { int x[x]; int y = sizeof(x) / sizeof(int); return 0; }
- 0
- 5
- undefined
- 2
what is the output of the programme? #define ABC 20 #define XYZ 10 #define XXX ABC - XYZ void main() { int a; a = XXX * 10; printf("%d ", a); }
- 20
- 10
- 100
- -80
what is the output? int a = 400; void main() { int b; b=(400 * 400)/ a ; printf("%d",b); }
- compilation error
- garbage value
- 400
- 1
Print the output of this program main() { int k = 5; if (++k < 5 && k++/5 || ++k <= 8); printf("%d\n", k); }
- 5
- 7
- 8
- garbage value
What is the result Integer i1=10; Integer i2=10; (i1==i2)-->result of this
- True
- False
What is result of the question Integer i1=10; Integer i2=10; (i1!=i2)-->result is
- True
- False
What is the result of this Integer i1=10; int i2=10; (i1==i2)-->result is
- True
- False
What is the result os this String s1="hi"; String s2="hi"; (s1==s2)-->returns
- true
- false
- compilation error
- exception thrown at runtime
String s1=new String("abc"); String s2=new String("abc"); (s1==s2)-->result is
- true
- false
- compilation error
- exception thrown at runtime
Integer i1=10; Integer i2=10; (i1.equals(i2++))-->result is
- true
- false
- compilation error
- exception thrown at runtime
LINQ is abbreviation of
- Language Integrated Query
- Language Independent Query
- Language Interrelated Query
- None of the above
In which version of .Net framework LINQ has been introduced
- 2.0
- 3.0
- 3.5
- 4.0
Features of LINQ
- Querying of in-memory collections
- Abstraction layer of data sources
- Object and Collection Initializers
- Lambda expressions
Features of LINQ
- Querying of in-memory collections
- Abstraction layer of data sources
- Object and Collection Initializers
- Lambda expressions
List Names = new List(); Names.Add("A"); Names.Add("B"); Names.Add("C"); var res = Names.Where(n => n == "D"); if (res == null) Console.WriteLine("res is null"); else Console.WriteLine("res is not null"); Console.Read(); What would be printed?
- res is null
- res is not null
- Run time error
- None of the above
List Names = new List(); Names.Add("A"); Names.Add("B"); Names.Add("C"); var res = Names.Where(n => n == "D"); res is the type of
- List<string>
- IEnumerable<string>
- List<object>
- IEnumerable<object>
Anonymous Types is a feature of LINQ
- True
- False
What will happen when you attempt to compile and run the following code? int Output = 10; boolean b1 = false; if((b1 == true) && ((Output += 10) == 20)) { System.out.println("We are equal " + Output); } else { System.out.println("Not equal! " + Output); }
- Compilation and output of "Not equal! 10".
- Compilation and output of "Not equal! 20".
- Compilation and output of "We are equal 10".
- Compilation error, attempting to perform binary comparison on logical data type.