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.

20 Questions Published

Questions

Question 1 True/False

A function call is always an rvalue. True or false?

  1. True
  2. False
Question 2 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; }

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

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; }

  1. 0
  2. 5
  3. undefined
  4. 2
Question 4 Multiple Choice (Single Answer)

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); }

  1. 20
  2. 10
  3. 100
  4. -80
Question 5 Multiple Choice (Single Answer)

what is the output? int a = 400; void main() { int b; b=(400 * 400)/ a ; printf("%d",b); }

  1. compilation error
  2. garbage value
  3. 400
  4. 1
Question 6 Multiple Choice (Single Answer)

Print the output of this program main() { int k = 5; if (++k < 5 && k++/5 || ++k <= 8); printf("%d\n", k); }

  1. 5
  2. 7
  3. 8
  4. garbage value
Question 7 True/False

What is the result Integer i1=10; Integer i2=10; (i1==i2)-->result of this

  1. True
  2. False
Question 8 True/False

What is result of the question Integer i1=10; Integer i2=10; (i1!=i2)-->result is

  1. True
  2. False
Question 9 True/False

What is the result of this Integer i1=10; int i2=10; (i1==i2)-->result is

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

What is the result os this String s1="hi"; String s2="hi"; (s1==s2)-->returns

  1. true
  2. false
  3. compilation error
  4. exception thrown at runtime
Question 11 Multiple Choice (Single Answer)

String s1=new String("abc"); String s2=new String("abc"); (s1==s2)-->result is

  1. true
  2. false
  3. compilation error
  4. exception thrown at runtime
Question 12 Multiple Choice (Single Answer)

Integer i1=10; Integer i2=10; (i1.equals(i2++))-->result is

  1. true
  2. false
  3. compilation error
  4. exception thrown at runtime
Question 13 Multiple Choice (Single Answer)

LINQ is abbreviation of

  1. Language Integrated Query
  2. Language Independent Query
  3. Language Interrelated Query
  4. None of the above
Question 14 Multiple Choice (Single Answer)

In which version of .Net framework LINQ has been introduced

  1. 2.0
  2. 3.0
  3. 3.5
  4. 4.0
Question 15 Multiple Choice (Multiple Answers)

Features of LINQ

  1. Querying of in-memory collections
  2. Abstraction layer of data sources
  3. Object and Collection Initializers
  4. Lambda expressions
Question 16 Multiple Choice (Multiple Answers)

Features of LINQ

  1. Querying of in-memory collections
  2. Abstraction layer of data sources
  3. Object and Collection Initializers
  4. Lambda expressions
Question 17 Multiple Choice (Single Answer)

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?

  1. res is null
  2. res is not null
  3. Run time error
  4. None of the above
Question 18 Multiple Choice (Single Answer)

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

  1. List<string>
  2. IEnumerable<string>
  3. List<object>
  4. IEnumerable<object>
Question 19 True/False

Anonymous Types is a feature of LINQ

  1. True
  2. False
Question 20 Multiple Choice (Multiple Answers)

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); }

  1. Compilation and output of "Not equal! 10".
  2. Compilation and output of "Not equal! 20".
  3. Compilation and output of "We are equal 10".
  4. Compilation error, attempting to perform binary comparison on logical data type.