Linq Basic questions


1.  The full form of LINQ is ________

2. Which of the following supports LINQ queries?
  • Object collection
  • XML Document
  • Entity Framework
  • All of the above
3.  A class must implement ____________ interface in order to provide querying facility using LINQ.

4. Third-party data providers must implement ________ interface, in order to support LINQ.
  • IEnumerable
  • IQueryable
  • ICollection
  • IEnumerator
 5. LINQ supports which of the following syntaxes?
  • Query syntax 
  • Method syntax 
  • All of the above 
  • None of the above
6. var teenAgerStudent = from s in studentList where s.Age > 12 && s.Age < 20 select s; The above query is an example of ________ syntax.
  • Query syntax 
  • Method syntax 
  • All of the above 
  • None of the above 
7.  var teenAgerStudents = studentList.Where(s => s.Age > 12 && s.Age < 20) .ToList(); The above query is an example of _______ syntax. 
  • Query syntax 
  • Method syntax 
  • All of the above 
  • None of the above  
8. Which of the following statement is TRUE?

The lambda expression is nothing but extension method.
The lambda expression is a shorter way of representing anonymous methods.
The lambda expression is a style of representing dynamic types.
The lambda expression is nothing but static delegate method.

9. s => s.Age > 12 && s.Age < 20; is an example of _______. 
  • Expression tree
  • LINQ query 
  • C# condition 
  • Lambda expression
10. Lambda expression can be invoked like a delegate.
  • True 
  • False 
  • Sometime true 
  • Sometime false. 
11. OrderByDescending is NOT supported in _______.
  • Query syntax
  • Method syntax
  • Lambda expression
  • VB Method syntax. 
12.  Which of the following standard query operator returns the differences between the two collections?
  • Distinct
  • Except
  • Intersect
  • Union
13. Which of the following standard query operator returns the unique elements from two collections?
  • Distinct
  • Except
  • Intersect
  • Union
14. Which of the following standard query operator returns the common elements from two collections?
  • Distinct
  • Except
  • Intersect
  • Union
 15. Which of the following is TRUE?
  • An Expression compiles into executable code.
  • An Expression compiles into expression tree.
  • An expression compiles into native code.
  • An Expression compiles into machine code. 
 16.  Expression tree is _________.
  • Tree of expression in C# or VB.
  • Executable tree structure.
  • In-memory representation of lambda expression.
  • Binary tree like data structure for better LINQ support. 
17.  Which of the following operators executes LINQ query immediately and gets the result?
  • 'To' operators
  • Casting operators
  • Grouping operators
  • Joining operators
18.  What is the difference between First and FirstOrDefault?
  • First throws an exception whereas FirstOrDefault returns default value, if no elements found for specified criteria.
  • First returns NULL whereas FirstOrDefault returns default value, if no elements found for specified criteria.
  • First throws an exception whereas FirstOrDefault returns NULL, if no elements found for specified criteria.
  • First returns void whereas FirstOrDefault returns NULL value, if no elements found for specified criteria.
19. LINQ supports ________   language syntax. 

20. Which of the following statement is TRUE?
  • LINQ API is a bunch of extension methods included in System.Linq.Enumerable and System.Linq.Queryable class.
  • LINQ API is a bunch of abstract methods included in Enumerable and Queryable classes.
  • LINQ API is bunch of queries written in C# and VB.
  • None of the above







Answers :

1. Language Integrated Query Language

2. All of the above

3. IEnumerable or IQueryable

4. IEnumerable or IQueryable

5.  All of the above

6. Query syntax

7.  Method syntax

8. The lambda expression is a shorter way of representing anonymous methods.

9.  Lambda  Expression

10. True

11. Query syntax

12. Except

13. Union

14.  Intersect

15. An Expression compiles into expression tree.

16.  In-memory representation of lambda expression.

17. 'To' operators

18.   First throws an exception whereas FirstOrDefault returns default value, if no elements found for specified criteria.

19. C# and VB

20.  LINQ API is a bunch of extension methods included in System.Linq.Enumerable and System.Linq.Queryable class.

No comments:

Post a Comment

Pages