Select chapter



Basics (5.papers)

Sponsored Links


  

linq questions and answers

1
How to add two lists ?
  1.  List1+list2
  2. List1.Add(List2)
  3. List1.Concat(List2).ToList()
  4.  Both b and c
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
3
What is full form of linq ?
  1.  Language Integrated Query
  2. Language Interaction Query
  3. Language interpretability and query
  4.   None of the above
Show Answer
Share Facebook gmail Twitter
4
Which dotnet version supports linq ?
  1. .Net 3.0
  2.  .Net 3.5
  3. .Net 4.0
  4.   All of the above
Show Answer
Share Facebook gmail Twitter
5
Which object create xml document ?
  1. XmlDocument
  2. Xdocument
  3. Both a and b
  4. None of the above
Show Answer
Share Facebook gmail Twitter
6
112) Which object creates comments
EX:
<!----This is an xml document--->
<Members>
<FirstName>Shaiksha</FirstName>
<LastName>Vali</LastName>
<Age>27</Age>
</Members>
  1. new XComment(”This is an xml document”)
  2. new XmlComment(“This is an xml document”);
  3. new Comment(“This is an xml document”);
  4. none of the above
Show Answer
Share Facebook gmail Twitter
7
which object creates Xml Element ?
  1. XElement
  2. XMLElemen
  3. Both a and b
  4.   None of the above
Show Answer
Share Facebook gmail Twitter
8
The List lstProjects contains the below data. How to convert this into xml using linq ? 
projectcodeProjectname baselineversion
IND000001Project10
IND000002Project20
IND000001Project31
IND000002Project41
  1. var q = from projects in lstProjects 
    select new XElement(”Project”,
    new XElement(”ProjectCode”,projects.projectcode),
    new XElement(”ProjectName”,projects.projectname),
    new XElement(”BaseLineVersion”,projects.baselineversion));
    XDocument doc = new XDocument(
    new 
    XComment(”Projects Stats”),
    new XElement(”Projects”, q)
    );
  2. var q = from projects in lstProjects.Take(2)
    select new XmlElement(”Project”,
    new XmlElement(”ProjectCode”,projects.projectcode),
    new XmlElement(”ProjectName”,projects.projectname),
    new XmlElement(”BaseLineVersion”,projects.baselineversion));
    XDocument doc = new XDocument(
    new XmlComment(”Summarized Incoming Call Stats”),
    new XmlElement(”Information”, q)
    );
  3. var q = from projects in lstProjects. ToLookup()
    select new XElement(”Project”,
    new XmlElement(”ProjectCode”,projects.projectcode),
    new XmlElement(”ProjectName”,projects.projectname),
    new XmlElement(”BaseLineVersion”,projects.baselineversion));
    XDocument doc = new XDocument(
    new XComment(”Summarized Incoming Call Stats”),
    new XmlElement(”Information”, q)
    );
  4. both and b
Show Answer
Share Facebook gmail Twitter
9
Which keyword creates local variable ?
  1. Let 
  2. Set
  3. Var 
  4. All of the above
Show Answer
Share Facebook gmail Twitter
10
Which keyword is not related to linq ?
  1.   ToArray()
  2. ToList()
  3. Distinct()
  4. None of the above
Show Answer
Share Facebook gmail Twitter
11
The List<DateTime> lstDates contains three months dates. How to get dates without Saturday and Sunday using linq ?
  1. List<DateTime> p=(from c in lstDates where c.Date.DayOfWeek!=DayOfWeek.Saturday &&
    c.Date.DayOfWeek!=DayOfWeek.Saturday select c.Date).ToList().ConvertAll(t=>t.Date);
  2. List<DateTime> p=from c in lstDates where c.Date.DayOfWeek!=DayOfWeek.Saturday &&
    c.Date.DayOfWeek!=DayOfWeek.Saturday select c.Date;
  3.     Both a and b;
  4. None of the above
Show Answer
Share Facebook gmail Twitter
12
The above List<DateTime> lstDates contains 3 months dates. How to get first five dates only from list using linq ?
  1. var p=(from c in lstDates where select c.Date)
    .Take(5);
  2. Var p=(from c in lstDates where select c.Date).Select(5);
  3. Var p=(from c in lstDates where select c.Date).Consider(5);
  4. All of the above
Show Answer
Share Facebook gmail Twitter
13
Your application contains ajax autocomplete extender. Autocomplete extender  searching names based on entering characters(input). Which below linq query is using 
for autocomplete extender 

Note:  PrefixText user entering characters(input)
  1. List<string> lstNames = GetAllResources(prefixText);
    List<string> listNames = (from i in lstNames where i.StartsWith(prefixText) select i).ToArray();
  2. List<string> lstNames = GetAllResources(prefixText);
              String[] Names = (from i in lstNames where i.StartsWith(prefixText) 
                select i).ToArray();
  3. Both a and b
  4. None of the above
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
15
How to add data to List<string> ?
  1. a. List<string> lst=new List<string>();
    lst.add(“India”);
    lst.add(“Australia”);
    
  2. List<string> lst=new List<sting>(“India”,”Australia”);
  3. List<string> lst=new List<sting>{“India”,”Australia”};
  4.  Both a and c
Show Answer
Share Facebook gmail Twitter
16
How to call for below method from linq ?
Ex: Public static class A
{
        Public List<string> GetMembers()
        {   
                Return List<string>();
         }
}
  1. From p in A.GetMembers() select p;
  2. From p in lstMembers select new{A.GetMembers()};
  3.  Both a and c
  4. None of the above
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
18
List1
hr_buprojectid pc_bu
IN006IND000001IN006
IN006IND000002IN006
US347IND000002IN006
US753IND000002IN006
List2
projectcodeProjectname baselineversion
IND000001RM ONLY-BNGLRFSNT-MNT0
IND000002RM ONLY-ESETTLEMENT-MNT0
IND000001RM ONLY-BNGLRFSNT-MNT1
IND000002RM ONLY-ESETTLEMENT-MNT1
How to join two lists and result of linq should be hr_bu, pc_bu, projectname ?
  1. Var a=from p in List1 inner join List2 select new {p.hr_bu,p.pc_bu,p.projectname,p.baselineversion};
  2. Var a= from p in List1
        Inner join a in List2 on p.ProjectID=a.ProjectCode select new {p.hr_bu,p.pc_bu,a.projectname,a.baselineversion};
  3. Var a=from p in List1 join a in List2 on p.ProjectID equals a.ProjectCode
       {p.hr_bu,p.pc_bu,a.projectname};
  4. Both b and c
Show Answer
Share Facebook gmail Twitter
19
How to user ternary operator(?) in linq. ?
  1. var q1 = from c in lstCountry group c by 
          c.State == null ? ”(null)” : c.State
    
  2. var q1 = lstCountry.group c by c.State == null ? ”(null)” : c.State;
  3. both and b
    
  4. None of the above
    
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Read more papers :