Linq(Computer Science ) Questions and Answers

Question 1. Choose the namespace in which Expression trees are encapsulated:
  1.    System.Linq
  2.    System.Linq.Expressions
  3.    System.Text
  4.    System.Collections.Generic
Explanation:-
Answer: Option B. -> System.Linq.Expressions

Question 2. Select the namespace which should be included while making use of LINQ operations:
  1.    System.Text
  2.    System.Collections.Generic
  3.    System.Linq
  4.    none of the above
Explanation:-
Answer: Option C. -> System.Linq

Question 3. What can LINQ be used to access?
  1.    Databases and Data Sources
  2.    Only Collections
  3.    Only Databases
  4.    Value Types
Explanation:-
Answer: Option A. -> Databases and Data Sources

Question 4. Can we use linq to query against a DataTable?
  1.    Yes
  2.    No
  3.    Either Yes or No
  4.    None of the above
Explanation:-
Answer: Option B. -> No

Question 5. Choose the namespace in which the interface IEnumerable is declared?
  1.    System.Collections
  2.    System.Collections.Generic
  3.    Both a & b
  4.    none of the above
Explanation:-
Answer: Option B. -> System.Collections.Generic

Question 6. Choose the wrong statement about the LINQ?
  1.    The main concept behind the linq is query
  2.    linq makes use of foreach loop to execute the query
  3.    It is not required that linq should make use of IEnumerable interface
  4.    none of the above
Explanation:-
Answer: Option C. -> It is not required that linq should make use of IEnumerable interface

Question 7. Assume 2 columns named as Product and Category how can be both sorted out based on first by category and then by product name?
  1.    var sortedProds = _db.Products.Orderby(c => c.Category)
  2.    var sortedProds = _db.Products.Orderby(c => c.Category) + ThenBy(n => n.Name)
  3.    var sortedProds = _db.Products.Orderby(c => c.Category) . ThenBy(n => n.Name)
  4.    none of the above
Explanation:-
Answer: Option C. -> var sortedProds = _db.Products.Orderby(c => c.Category) . ThenBy(n => n.Name)

Question 8. Which of the following namespace contains the LINQ to XML?
  1.    System.Xml.Linq
  2.    System.Linq;
  3.    System.Xml;
  4.    None of these
Explanation:-
Answer: Option A. -> System.Xml.Linq

Question 9. What do you use to retrieve the data in a particular order?
  1.    GroupBy
  2.    OrderBy
  3.    ThenBy
  4.    Zomato
Explanation:-
Answer: Option B. -> OrderBy

Question 10. Whose presentation was the best?
  1.    Aweez
  2.    Aweez, of course
  3.    Bruh, don't even ask
  4.    All of above
Explanation:-
Answer: Option D. -> All of above