C++, Java, and .NET Programming Concepts

Quiz covering core programming concepts in C++ (constructors, destructors, memory allocation, OOP), Java (operators, data types, exceptions), and .NET (ADO.NET, LINQ)

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

LINQ query to Select and return all the rows from Product table and display the product names.

  1. Dim query = From product In products.AsEnumerable() Select product
  2. Dim query as select product From product In products.AsEnumerable()
  3. Dim query = From p In products.AsEnumerable() Select p
  4. None of these
Question 2 Multiple Choice (Single Answer)

Method used in LINQ to SQL for database updation

  1. Commit();
  2. Update();
  3. SubmitChanges();
  4. CommitTransaction();
Question 3 Multiple Choice (Single Answer)

Which is not the an ADO.NET object

  1. SqlDataAdapter
  2. SqlConnection
  3. SqlDataReader
  4. SqlDataView
Question 4 Multiple Choice (Single Answer)

Which is/are the method/s of an ADO.NET command object

  1. CreateObjRef
  2. BeginExecuteNonQuery
  3. Prepare
  4. All of the above
Question 5 True/False

Is the following statement correct: char ch = 'd'; if(ch < 32.00){ }

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

What will be output from the following statements: System.out.println(1+2+”3”); System.out.println (“1”+2+3);

  1. 33,123
  2. 123,33
  3. 6,6
  4. Compilation Error
Question 7 True/False

Is following line throws Exception.If yes ,which type? justify it . float f = 100.00/0.0

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

what is the output? class A{ int i=1; void printit() { i=i++; system.out.println(i);} } class AS { public static void main(String s[]) { A a=new A(); a.printit(); } }

  1. 1
  2. 2
  3. Error
  4. None
Question 9 Multiple Choice (Single Answer)

Which one is faster in java ? A. Math.max(a,b); B. (a>b)?a:b

  1. A
  2. B
  3. Both are Same
  4. None
Question 10 Multiple Choice (Single Answer)

Which of the following is(are) true for Macro functions(#define fn()) & inline functions

  1. macro functions are expanded during compile. Inline functions are just usual functions calls
  2. macro functions are expanded during preprocessing and inline functions are expanded during compile
  3. macro functions are expanded during compile and inline functions are expanded during preprocessing
  4. No difference.Both are expanded at compile.
Question 11 Multiple Choice (Single Answer)

Considereing int take 2 bytes of memory. What is size of memory allocated for ob in the below program.the size of memory allocated for object of class class my_class { int x; int y; public: void add(int k); void display(); }; my_class ob;

  1. 4 bytes
  2. 6 bytes
  3. 8 bytes
  4. 12 bytes
Question 12 Multiple Choice (Single Answer)

What is abstract class?

  1. A class which can not be inherited
  2. A class which can have only single object
  3. A class which can not have any objects
  4. A class which can not inherit other classes
Question 13 Multiple Choice (Single Answer)

How is dynamic binding achieved in C++?

  1. Using virtual functions
  2. Using method overloading
  3. Using operator overloading
  4. Using both method & operator overloading
Question 14 Multiple Choice (Multiple Answers)

Which of the following statement(s) is(are) correct?

  1. constructors can be virtual
  2. destructors can be virtual
  3. constructors can be overloaded
  4. virtual functions are fast in execution
Question 15 Multiple Choice (Single Answer)

void func(){ double d; static int si; int i; }; where will be memory allocated for the variables?

  1. all(d,si,i) in stack
  2. d in stack;si in heap;i in stack
  3. d in stack;si in stack;i in heap
  4. d in heap;si in heap;i in stack
Question 16 Multiple Choice (Multiple Answers)

Which of the following statment(s) is(are) true for constructors & destructors

  1. constructors are executed only(once) when the first object is instantiated
  2. destructor is executed only at the end of main() execution
  3. constructors are executed on every object instantiation
  4. destructor is executed when all the objects of the class moves out of scope
  5. constructors can not take parameters
Question 17 Multiple Choice (Multiple Answers)

int he below code, which declaration hold for copy constructor? class C{ int x; public: C(int t);//-----> (1) C(C t); //-----> (2) C(C& t); //-----> (3) C(C t, int k);// ------> (4) };

  1. (1)
  2. (2)
  3. (3)
  4. (4)
Question 18 Multiple Choice (Single Answer)

What is singleton class?

  1. that can not be inherited
  2. that can be inherited only once
  3. that can have only one object
  4. there is no such class
Question 19 Multiple Choice (Multiple Answers)

which of the below statemen(s)is(are) true for malloc() & new functions?

  1. malloc is used to allocate store for integer arrays only
  2. new is used to allocate store for objects only
  3. new is used to allocate any kind of memory
  4. malloc is used to allocate any kind of memory
  5. new initializes the store after allocation
  6. malloc intializes the store after allocation
Question 20 True/False

Pass by reference and Pass by address are same in C++.

  1. True
  2. False