Basics (5.papers)

1

When var keyword is used?

var keyword is used if we don’t know the return type of the query.

var keyword is used when query returns string

var keyword is used when query return string[]

All of the above

Show Answer

2

What is the difference between OrderBy() and Sort() method over IList?

OrderBy() sorts and gives the view IEnumerable(). But underlying list is sorted or not changed. Sort() modifies the underlying list.

OrderBy will sort based on particular parameter and sort will sort based on all the elements in the list or dataset

Both a and b

None of the above

Show Answer

3

What is the difference between Select() and SelectMany()?

Select() converts one type to another and returns enumerable. SelectMany() flattens the elements and gives a combined list of elements.

Select() converts one type to another and returns ToQueryable(). Select Many() flattens the elements and gives a individual list of elements.

Both a and b

None of the above.

Show Answer

Show Answer

Show Answer

6

How to get the count of odd numbers in a list. Below numbers is a generic List<int> ?

int oddNumbers=numbers. Count(n=>n%4==1)

int oddNumbers=numbers. Count(n=>n%2==0)

int oddNumbers = numbers. Count(n => n % 2 == 1);

None of the above

Show Answer

7

How to return only the elements of the array that are of particalur type?

Using method .OfType<type>()

Using method .OfType()

Using method . GetType<type>()

All of the above

Show Answer

8

How to retrieve the second number from an array?

Using method .ElementAt(1)

Using method . GetElementAt(1)

Using method .IndexOf(1)

Both a, b & c

Show Answer

9

How to retrieve first element in the array?

Using method .First()

Using method .ElementAt(1)

Using method .GetElementAt(1)

Using method .IndexOf(1)

Show Answer

10

How to generate a sequence of numbers from 100 to 149?

List.Range(100,50)

List.Range(100,149)

List.Range(100,150).set(-2)

Both a and b

Show Answer

11

How to create one sequence that contains each array's values, one after the other?

var allNumbers=numbersA. ToList(numbersB).

var allNumbers = numbersA. Concat(numbersB);

bool match=workdsA. wordsb.sequnce()

None of the above

Show Answer

12

How to sort a list by length?

var sortedList =from w in List orderby w.Length select w;

var sortedList= List.order(t->t.length);

both a and b

None of the above

Show Answer

13

How to get only the first 3 elements of the array?

var first3Numbers = numbers .Take(3);

var first3Numbers=numbers .Top(3)

var first3Numbers= numbers.First(3)

None of the above

Show Answer

14

How to get all but the first 4 elements of the array?

var allButFirst4Numbers = numbers.Skip(4);

var allButFirst4Numbers= numbers.Except(4)

var allButFirst4Numbers. numbers.ToList().Remove(4)

None of the above

Show Answer

15

How to get the elements of the array starting from the first element divisible by 3?

var allButFirst3Numbers = numbers.SkipWhile (n => n % 3 != 0);

codingpart@prettyprint var allButFirst3Numbers = numbers.Skip(n => n % 3 != 0);

codingpart@prettyprint var allButFirst3Numbers = numbers.DoWhile (n => n % 3 != 0);

All of the above

Show Answer

16

How to get the elements of the +C64 array starting from the first element less than its position?

var laterNumbers = numbers.SkipWhile((n, index) => n >= index);

var laterNumbers = numbers.Skip((n, index) => n >= index);

var laterNumbers = numbers.While((n, index) => n >= index);

all of the above

Show Answer

17

How to get the elements of the array starting from the first element less than its position?

var laterNumbers = numbers.SkipWhile((n, index) => n >= index);

var laterNumbers = numbers.Skip((n, index) => n >= index);

var laterNumbers = numbers.While((n, index) => n >= index);

all of the above

Show Answer

18

How to produce a sequence of ints one higher than those in an existing array of ints?

var numsPlusOne = from n in numbers select n + 1;

var numsPlusOne = from n in numbers select n + 2;

var numsPlusOne = from n in numbers select n + 3;

All of the above

Show Answer

19

How to make a simple query that returns the text form of each digit less than 5? Ex: int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 }; string[] digits = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };

var lowNums =from n in numbers where n < 5 select digits[n];

codingpart@prettyprint var lowNums=from n in numbers where n<5 select digits[numbers]

var lowNums=from n in numbers where n<5 select digits[n-1]

All of the above

Show Answer

20

How to produce a sequence of strings representing thetext version of a sequence of ints? Ex: int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 }; string[] strings = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}

var textNums =from n in numbers select strings[n];

var textNums =from n in numbers select new{strings[n]};

var textNums =from n in numbers select new{n[strings]}

All of the above

Show Answer