Arrays And Strings In C Sharp
Name: _____________________
Date: _____________________
Instructions: Answer all questions. Write your answers clearly in the space provided.
Which of these access specifiers must be used for main() method?
Which of these methods of the class String is used to obtain length of String object?
Which of these data type values is returned by equals() method of String class?
Correct way to convert a string to uppercase using string class method()?
Which of the following statements is true regarding arrays in C#?
Which method in C# is used to sort the elements of an array in ascending order?
What does the 'Length' property of an array in C# return?
Which of the following string() method are used to compare two strings with each other?
Which statement is/are correct?
Which of these methods of class String is used to compare two String objects for their equality?
Which of these is used to access members of class before the object of that class is created?
What is the value returned by function compareTo() if the invoking string is less than the string compared?
What does the term 'immutable' means in term of string objects?
Accessibility modifier defined in a class are?
Which of these methods is an alternative to getChars() that stores the characters in an array of bytes?
The modifiers used to define an array of parameters or list of arguments is . . . . . . . .
Which of these methods of class String is used to separate a substring from a String object?
Statements about 'ref' keyword used in C#.NET are?
Which of the following statement is correct about a string in C#.NET?
Which of these methods of class String is used to check whether a substring exists at the beginning of the particular string?
What is the String in C# meant for?
Which of these operators can be used to concatenate two or more String objects?
Which of these is used as a default specifier for a member of the class if no access specifier is used for it?
The method in which large or variable number of arguments are handled is known as . . . . . . . .
Choose the statements which are false in nature?
Keyword used to define call by reference parameter in C# .NET?
How is a string typically processed?
What is the advantage of using 2D jagged array over 2D rectangular array?
Which of the following statements are correct?
Which of the following methods is used to concatenate strings in C#?
Which method in C# is used to find the index of a specific element in an array?
Which of the following statements is true regarding strings in C#?
In C#, which keyword is used to declare an array?
What is the index of the first element in an array in C#?
Which method is used to find the length of an array in C#?
In C#, what is the default value of an uninitialized element in an integer array?
What is the correct way to access the third element in an array named numbers in C#?
In C#, which method is used to copy elements from one array to another?
What is the correct way to access the length of an array named numbers in C#?
In C#, which method is used to sort the elements of an array?
What does the Split() method do when applied to a string in C#?
In C#, which method is used to convert an array to a string representation?
What is the correct way to access the last element in an array named numbers in C#?
Which method is used to concatenate two or more strings in C#?
In C#, which method is used to find the index of the first occurrence of a specified value in an array?
In C#, what is the correct way to access the length of a string named text?
What does the IndexOf() method return if the specified value is not found in an array in C#?
What is the purpose of the Reverse() method when applied to an array in C#?
In C#, what method is used to convert a string to an array of characters?
The Method use to remove white space from a string?
Correct way to find if contents of two strings are equal?
Which of these methods can be used to convert all characters in a String into a character array?
Which of these methods returns the string such that some characters which are specified to be removed from the end of strings are removed from string by mentioning the number of characters to be removed?
To perform comparison operation on strings supported operations are . . . . . . . .
Select the correct declaration of the defining array of parameters.
Which of these methods is used to compare two strings such that after comparison output returns different integer values as (0 for false, 1 for true)?
Which of the following statements is correct?
Choose selective differences between an array in c# and array in other programming languages.
What is the correct syntax to access the second character of a string named text in C#?
What is the result of the expression Array.IndexOf(numbers, 5) where numbers = {1, 2, 3, 4, 5} in C#?
In C#, which method is used to split a string into substrings based on a specified delimiter?
Which of these methods of class String is used to extract all the characters from a String object?
Which of these base classes are accessible to the derived class members?
What is the process by which we can control parts of a program that can access the members of a class?
Which of these methods of class are used to remove the leading and backward whitespaces?
What is the correct syntax to declare a 2D array with 3 rows and 4 columns in C#?
What is the result of the expression string[] fruits = {"Apple", "Banana", "Orange"}
in C#?
What is the correct way to declare and initialize a string array with three elements in C#?
What will be the output of the following C# code? static void Main(string[] args)
{
String c = "Hello"
String a
a = c.Replace('l', 'w')
Console.WriteLine(a)
Console.ReadLine()
}
What will be the output of the following C# code snippet? static void Main(string[] args)
{
String c = "Hello i love you"
String a
a = c.Substring(12, 3)
Console.WriteLine(a)
Console.ReadLine()
}
What will be the output of the following C# code? static void Main(string[] args)
{
String obj = "hello"
String obj1 = "world"
String obj2 = obj
Console.WriteLine(obj + " " + obj1)
string s = obj + " " + obj1
Console.WriteLine(s.Length)
Console.ReadLine()
}
What will be the output of the following C# code? static void Main(string[] args)
{
String obj = "hello"
String obj1 = "world"
String obj2 = obj
Console.WriteLine (obj.Equals(obj2) + " " + obj2.CompareTo(obj) )
Console.ReadLine()
}
Choose the effective stringBuilder method which helps in producing output for the following C# code? static void Main(string[] args)
{
StringBuilder s = new StringBuilder("object")
s./*______*/("Oriented Language")
Console.WriteLine(s)
Console.ReadLine()
}
Output : objectOriented Language
What will be the output of the following C# code? static void Main(string[] args)
{
int[] x = {65, 66, 67, 68, 69, 70}
fun(x)
Console.ReadLine()
}
static void fun(params int[] b )
{
int i
for (i = 5
i > 0
i--)
{
b[i] = b[i] + 32
Console.WriteLine(Convert.ToChar(b[i]))
}
}
What will be the output of the following C# code? static void Main(string[] args)
{
String a = "Ilove"
String b = "CSHARP"
b = string.Concat(a,' ',b)
string d = b.TrimStart('I', 'l', 'o', 'H')
Console.WriteLine(d)
Console.ReadLine()
}
What will be the output of the following C# code? static void Main(string[] args)
{
double a = 345.09
byte c = (byte) a
Console.WriteLine(c)
Console.ReadLine()
}
What will be the output of the following C# code? class sum
{
public int x
private int y
public void math(int a, int b)
{
x = a * 4
y = b
}
}
class Program
{
static void Main(string[] args)
{
sum p = new sum()
p.math(12, 30)
Console.WriteLine(p.x + " " + p.y)
Console.ReadLine()
}
}
What will be the output of the following C# code? static void Main(string[] args)
{
String obj = "hello"
String obj1 = "worn"
String obj2 = obj
Console.WriteLine(obj + " " + (obj1.Replace('w' ,'c')))
Console.ReadLine()
}
What is the correct way to declare and initialize a jagged array with 2 rows in C#?
What is the correct way to declare and initialize a multidimensional array with 3 rows and 4 columns in C#?
What will be the output of the following C# code? class math
{
public int a,b
public math(int i, int j)
{
a = i
b = j
}
public void sum(math m)
{
m.a *= 2
m.b += 2
}
}
class Program
{
static void Main(string[] args)
{
math t = new math(20, 10)
t.sum(t)
Console.WriteLine(t.a + " " + t.b)
Console.ReadLine()
}
}
What will be the output of the following C# code? class Program
{
static void Main(string[] args)
{
String c = "i love Csharp"
bool a
a = c.StartsWith("I")
Console.WriteLine(a)
Console.ReadLine()
}
}
What will be the output of the following C# code? class Program
{
static void Main(string[] args)
{
int i = 5
int j
method1(ref i)
method2(out j)
Console.writeline(i + " " + j)
}
static void method1(ref int x)
{
x = x + x
}
static void method2(out int x)
{
x = 6
x = x * x
}
}
Which is the correct way of defining and initializing an array of 3 integers?
What will be the output of the following C# code? static void main(string[] args)
{
int n = 1
method(n)
console.Writeline(n)
method1(ref n)
console.Writeline(n)
}
static void method(int num)
{
num += 20
console.writeline(num)
}
static void method1(ref int num)
{
num += 20
console.writeline(num)
}
What will be the output of the following C# code? static void Main(string[] args)
{
String c = "Hello"
String a = c + "Bye"
Console.WriteLine(a)
Console.ReadLine()
}
What will be the output of the following C# code? static void Main(string[] args)
{
char A = 'K'
char B = Convert.ToChar(76)
A++
B++
Console.WriteLine(A+ " " +B)
Console.ReadLine()
}
What is the result of the following code in C#: string[] fruits = {"Apple", "Banana", "Orange"}
Console.WriteLine(fruits[1])
What is the correct way to declare and initialize a jagged array in C#?
What is the correct syntax to initialize an array in C#?
What is the correct way to declare a string array named colors with three elements in C#?
What is the result of the expression string[] names = {"John", "Alice", "Bob"}
in C#?
What is the correct way to declare a jagged array in C#?
What is the correct syntax to declare a multidimensional array in C#?
What will be the output of the following C# code? class Program
{
static void Main(string[] args)
{
String []chars = {"z", "x", "y", "z", "y"}
for (int i = 0
i < chars.Length
++i)
for (int j = i + 1
j < chars.Length
++j)
if(chars[i].CompareTo(chars[j]) == 0)
Console.WriteLine(chars[j])
Console.ReadLine()
}
}
What will be the output of the following C# code? static void Main(string[] args)
{
string s1 = "Hello" + " I " + "Love" + " ComputerScience "
Console.WriteLine(s1)
Console.ReadLine()
}
What will be the output of the following C# code? String a = "Csharp"
String b = "CSHARP"
int c
c = a.CompareTo(b)
Console.WriteLine(c)
Complete the following C# code with "foreach condition". int[][]a = new int[2][]
a[0] = new int[3]{3, 4, 2}
a[1] = new int[2]{8, 5}
foreach( int[]i in a)
{
/* add for loop */
console.write( j+ " ")
console.writeline()
}
What will be the output of the following C# code? static void Main(string[] args)
{
Program p = new Program()
p.display(2, 3, 8)
int []a = { 2, 56, 78, 66 }
Console.WriteLine("example of array")
Console.WriteLine("elements added are")
p.display(a)
Console.ReadLine()
}
public void display(params int[] b)
{
foreach (int i in b)
{
Console.WriteLine("ARRAY IS HAVING:{0}", i)
}
}
What will be the output of the following C# code? static void main(string[] args)
{
int []arr = new int[]{ 1, 2, 3, 4, 5}
fun (ref arr)
for (int i = 0
i < arr.Length
i++)
Console.WriteLine( arr[i] + " ")
}
static void fun(ref int[]a)
{
a = new int[6]
a[3] = 32
a[1] = 24
}
What will be the output of the following C# code? static void Main(string[] args)
{
string s1 = " Cshr "
string s2 = s1.Insert(3 , " a ")
string s3 = s2.Insert(5 , " p ")
for (int i = 0
i < s3.Length
i++)
Console.WriteLine(s3[i])
Console.ReadLine()
}
What will be the output of the following C# code? static void Main(string[] args)
{
string s1 = "Hello I Love Csharp "
Console.WriteLine(Convert.ToChar( (s1.IndexOf('I') - s1.IndexOf('l')) * s1.IndexOf('p'))
Console.ReadLine()
}
Which among the following is the correct way to find out the index of second 's' in the string "She sold her beauty in one night to someone else"?
What will be the output of the following C# code? static void Main(string[] args)
{
string s1 = "Hello"
string s2 = "hello"
if (s1 == s2)
Console.WriteLine("Equal")
else
Console.WriteLine("Unequal")
if (s1.Equals (s2))
Console.WriteLine("Equal")
else
Console.WriteLine("Unequal")
Console.ReadLine()
}
What will be the output of the following C# code snippet? static void main(String args[])
{
char chars[] = {'x', 'y', 'z'}
String s = new String(chars)
Console.WriteLine(s)
}
What is the correct way to declare a string array in C#?
How do you access the first element of an array named 'numbers' in C#?
What is the correct way to initialize an array of integers with values {1, 2, 3} in C#?
How do you find the number of elements in an array named 'values' in C#?
What is the correct syntax to declare and initialize a 2D array in C# with dimensions 3x3?
What is the correct way to declare an array of strings with 5 elements in C#?
How do you access the last element of an array named 'values' in C#?
What will be the output of the following C# code? static void Main(string[] args)
{
int [] a = {1, 2, 3, 4, 5}
fun(a)
Console.ReadLine()
}
static void fun(params int[] b )
{
int[] k = { 3, 4, 7, 8,'x00' }
for (int i = 0
i < b.Length
i++)
{
b[i] = b[i] + k[i]
Console.WriteLine( b[i] + " ")
}
}
Which statement is correct about following c#.NET code? int[] a= {11, 3, 5, 9, 6}
What will be the output of the following C# code? static void Main(string[] args)
{
int[] a = { 2, 21, 34, 46, 85, 88, 90}
fun(a)
Console.WriteLine(a + " ")
Console.ReadLine()
}
static void fun(params int [] b )
{
int [] c = { 1, 2, 3, 4, 5, 6, 7}
int i
for (i = 0
i < b.Length
i++)
if (b[i] % 2 == 0)
{
c[i] = b[i]
}
Console.WriteLine("even numbers are:")
for (i = 0
i <= b.Length
i++)
{
Console.WriteLine(c[i])
}
}
How to print on the screen?
What will be the output of the following C# code? static void Main(string[] args)
{
int a = 5
int b = 0, c = 0
method (a, ref b, ref c)
Console.WriteLine(b + " " + c)
Console.ReadLine()
}
static int method(int x, int p, ref int k)
{
p = x + x * x
k = x * x + p
return 0
}
What will be the output of the following C# code? static void Main(string[] args)
{
String a = "Ilove"
String b = "CSHARP"
b = string.Concat(a, ' ', b)
Console.WriteLine(b)
Console.ReadLine()
}
What will be the output of the following C# code? static void Main(string[] args)
{
String obj = "hello"
String obj1 = "world"
String obj2 = obj
string s = obj+" "+obj1
Console.WriteLine(s.IndexOf('r'))
Console.ReadLine()
}
What will be the output of the following C# code? static void main(string[] args)
{
int i
int res = fun (out i)
console.writeline(res)
console.readline()
}
static int fun(out int i)
{
int s = 1
i = 7
for (int j = 1
j <= i
j++ )
s = s * j
return s
}
What will be the output of the following C# code? static void Main(string[] args)
{
String obj = "hello"
String obj1 = "world"
String obj2 = obj
string s = obj + " " + obj1
Console.WriteLine(s.Substring(6 ,5))
Console.ReadLine()
}
What will be the output of the following C# code? static void Main(string[] args)
{
int i, j
int[, ] arr = new int[ 3, 3]
for (i = 0
i < 3
++i)
{
for (j = 0
j < 3
++j)
{
arr[i, j] = i * 2 + i * 2
Console.WriteLine(arr[i, j])
}
Console.ReadLine()
}
}
What will be the output of the following C# code? static void Main(string[] args)
{
object[] a = {" 1 ", 4.0f, " harsh "}
fun(a)
Console.ReadLine()
}
static void fun(params object[] b)
{
for (int i = 0
i < b.Length - 1
i++)
Console.WriteLine(b[i] + " ")
}
What will be the output of the following C# code? class sum
{
public int x
public int y
public int add (int a, int b)
{
x = a + b
y = x + b
return 0
}
}
class Program
{
static void Main(string[] args)
{
sum obj1 = new sum()
sum obj2 = new sum()
int a = 2
obj1.add(a, a + 1)
obj2.add(5, a)
Console.WriteLine(obj1.x + " " + obj2.y)
Console.ReadLine()
}
}
What will be the output of the following C# code? static void Main(string[] args)
{
String c = " Hello Computer "
String a = c.Trim()
Console.WriteLine(""" + s + """)
}
Select the correct match of parameter declaration. static Void main(string[] args)
{
int a = 5
int b = 6
float c = 7.2f
math (ref a, ref b, ref c)
Console.WriteLine(a + " " + b + " " + c)
}
static int math(/*add parameter declaration */)
{
a += b
b *= (int)c
c += a * b
return 0
}
What will be the output of the following C# code? static void Main(string[] args)
{
int[] x = { 80, 82, 65, 72, 83, 67 }
fun(x)
Console.ReadLine()
}
static void fun(params int [] b )
{
int i
for (i = 5
i >=0
i--)
{
Console.WriteLine(Convert.ToChar(b[i]))
}
}
What will be the output of the following C# code snippet? static void Main(string[] args)
{
string c = "hello"
string c1 = c.Remove(1)
Console.WriteLine(c1)
Console.ReadLine()
}
Which method does following C# code explains? static void Main(string[] args)
{
int a = 10, b = 20
method(ref a, ref b)
console.writeline(a + " " + b)
}
static void swap(ref int i, ref int j)
{
int t
t = i
i = j
j = t
}
What will be the output of the following C# code? static void Main(string[] args)
{
int [] a = {1, 2, 3, 4, 5}
fun(a)
Console.ReadLine()
}
static void fun(params int[] b )
{
for (int i = 0
i < b.Length
i++)
{
b[i] = b[i] * 5
Console.WriteLine(b[i] + "")
}
}
Which statement is correct about following C# code? int[, ]a={{5, 4, 3},{9, 2, 6}}
What will be the output of the following C# code? class Program
{
static void Main(string[] args)
{
String s1 = "I love You"
String s2 = s1
Console.WriteLine((s1 == s2) + " " + s1.Equals(s2))
Console.ReadLine()
}
}
What will be the output of the following C# code? static void Main(string[] args)
{
string s = " i love you"
Console.WriteLine(s.IndexOf('l') + " " + s.lastIndexOf('o') + " " + s.IndexOf('e'))
Console.ReadLine()
}