TATA ELXSI Previous Years Solved Sample Placement Papers
-
Which of the following is responsible for converting bytecode into machine code?
a) JDK
b) JRE
c) JVM
d) Java Compiler
Ans: c) JVM -
What does JDK include?
a) Only a compiler
b) Only a runtime environment
c) Both a compiler and a runtime environment
d) None of the above
Ans: c) Both a compiler and a runtime environment -
What is the purpose of the continue statement in a loop?
a) To exit the loop immediately
b) To skip the current iteration and move to the next iteration
c) To terminate the program
d) To execute a specific block of code
Ans: b) To skip the current iteration and move to the next iteration -
Which loop construct in Java is best suited when the number of iterations is unknown?
a) for loop
b) while loop
c) do-while loop
d) none
Ans: b) while loop -
What will be the output of the following C# code?
using System; namespace MyApplication { class Program { static void Main(string[] args) { string[] mobiles = { "iPhone", "Samsung", "Vivo"}; Console.WriteLine(mobiles); } } }
A: "iPhone", "Samsung", "Vivo"
B: {"iPhone", "Samsung", "Vivo"}
C: string[]
D: System.String[]
Ans: DExplanation:
In the above code, the statement
Console.WriteLine(mobiles);
will print the type of the variable that isSystem.String[]
. -
What will be the output of the following C# code?
using System; namespace MyApplication { class Program { static void Main(string[] args) { string[] mobiles = {"iPhone", "Samsung", "Vivo"}; Console.WriteLine(mobiles[-1]); } } }
A: None
B: Warning
C: Exception
D: System.String[]
Ans: CExplanation:
The array index starts from 0 in C#. In the above code, we are trying to access an element with index -1, resulting in an exception:
System.IndexOutOfRangeException
. -
Which statement is correct about the following C# statement?
int[] x = {10, 20, 30};
A: 'x' is a reference to the array created on stack
B: 'x' is a reference to an object created on stack
C: 'x' is a reference to an object of a 'System.Array' class
D: None of the above
Ans: CExplanation:
In the above given C# statement, the variable
x
is a reference to an object of aSystem.Array
class. -
Which array property is used to get the total number of elements in C#?
A: Len
B: Length
C: Elements
D: MaxLen
Ans: BExplanation:
The
Length
property is used to get the total number of elements in C#.