Select chapter



Basics (5.papers)

Sponsored Links


  

linq questions and answers

1
How to create one sequence that contains the first letters of product names that are not also first letters of customer names?          
products customers
ProductNameCompanyName
  1. (from p in products select p.ProductName[0]).Except(from c in customers select c.CompanyName[0]);
  2. (from p in products select p.ProductName[0]).NotIn(from c in customers select c.CompanyName[0]);
  3. (from p in products select p.ProductName[0]).NotIn(from c in customers select c.CompanyName[0]);
  4. None
Show Answer
Share Facebook gmail Twitter
2
How to partition a list of words by their first letter?
          string[] words = { "blueberry", "chimpanzee", "abacus", "banana", "apple", "cheese" };
  1. var wordGroups = from w in words group w by w[0] into g select new { FirstLetter = g.Key, Words = g };
    
  2. var wordGroups = from w in words group w by w[1] into g select new { FirstLetter = g.Key, Words = g };
    
  3. var wordGroups = from w in words group w by w into g select new { FirstLetter = g.Key, Words = g };   
    
  4. None
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
6
How  to get the number of odd ints in the array?
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
  1. numbers.Count(n => n % 3 == 1);  
  2. numbers.Count(n => n % 2 == 1);
  3. numbers.Count(n => n % 2 == 0);  
  4.  none
Show Answer
Share Facebook gmail Twitter
7
How to get the total of the numbers in an array?
  1. numbers.Sum();
  2. numbers.Total();
  3. numbers.Count();              
  4. none
Show Answer
Share Facebook gmail Twitter
8
How to get the lowest number in an array?
  1. numbers.Max();
  2. numbers.High()
  3. numbers.Min();    
  4. numbers.Greater();
Show Answer
Share Facebook gmail Twitter
9
How to get the average of all numbers in an array?
  1. numbers.Avg();
  2. numbers.Average();   
  3. numbers.Aggregate();
  4. numbers.Sum(n+1/2);
Show Answer
Share Facebook gmail Twitter
10
How  to get the highest number in an array?
  1. numbers.Max();
  2. numbers.High()
  3. numbers.Average();
  4. numbers.Greater();
Show Answer
Share Facebook gmail Twitter
11
 How to convert dataset to list using linq ?
  1. Convert.ToList()
  2. ToList()
  3. List.Parse()
  4. None of the above
Show Answer
Share Facebook gmail Twitter
12
What is the use of linq ?
  1.  For filtering data
  2.  For sorting data
  3. For avoiding duplication
  4. All of the above
Show Answer
Share Facebook gmail Twitter
13
Linq is applicable only for  ?
  1. Data Set
  2. Generic Lists
  3.  Arrays (Ex. String[], Int[])
  4. All of the above
Show Answer
Share Facebook gmail Twitter
14
 How to convert list to array using linq ?
  1. To Array()
  2. To List()
  3. To String()
  4.  None of the above
Show Answer
Share Facebook gmail Twitter
15
Generic List  List  lstMembers contains
 the below data
Members Details
Nameagesal AddressDesig
Ashok2525000BangaloreSoftware Developer
Amar2222000HyderbadTester
Pavan2729000PuneTeam Lead
Kumar2118000BangaloreAssociate Software Developers
How to get member names and age based on whose age is more than 21 and below of 25 ?
  1. Var  MemberAge=from member in lstMembers where Age between 21 and 25 select member;
  2. Var  MemberAge=from member in lstMembers where Age>21 and Age<=25 select member;
  3. Var MemberAge= lstMembers .Where(t => t.Age>=20).Where(t=>t.Age<=22);
  4. None of the above
Show Answer
Share Facebook gmail Twitter
16
The List lstNames contains below member names.
Name
Ashok
Amar
Pavan
Kumar
Ravi
Vinod
Padma
Ram Mohan
Kiran
which below linq get whose member name starts with “A” ?
  1. var c=from k in lstNames where k.StartsWith("a") select k;
  2. var c =lstNames.Where(t => t.StartsWith("a"));
  3. both a and b
  4. none of the above
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
18
For the above example which linq returns 
the Name and Age as result set ?
  1. Var p=from c in lstMembers select p;
  2.  Var p=from c in lstMembers select {c.Name,c.Aget};
  3. Var p=from c in lstMembers select new{c.Name,c.Age};
  4. Var p=from c in lstMembers 
    select new{Name,Age};
Show Answer
Share Facebook gmail Twitter
19
 The dataset(dismembers) contains the above data. How to filter dataset data based on Address. Who are working in Bangalore.
  1. var query = from o in dismembers.ToQueryable()
    where o.Address == “Bangalore”
    select o;
  2. var query = from o in dismembers.ToEnemarable()
    where o.Field<string>("Address") == “Bangalore”
    select o;
  3.  both a and b
  4. none of the above
Show Answer
Share Facebook gmail Twitter
20
Which database linq is support?
  1.  MySql
  2.   SqlServer
  3. Oracle
  4.   All of the above
Show Answer
Share Facebook gmail Twitter
Read more papers :