0% found this document useful (0 votes)
3 views22 pages

Sample Interview Questions

Uploaded by

yadavshripad94
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views22 pages

Sample Interview Questions

Uploaded by

yadavshripad94
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

L1 interview questions:

1. What are the pillars of OOS.


The four pillars of OOPS (object-oriented programming) are Inheritance,
Polymorphism, Encapsulation and Abstraction

2. What is Ploymorphism
Ploymorphism is nothing but single thing having multiple form. There are
types of polymorphism Method overloading and method overriding.

3. What is encapsulation.
 Abstraction is a concept of showing necessary information to the outside
world.

 Encapsulation is a concept of hiding unnecessary information from the


outside world.

 Abstraction comes at design level whereas Encapsulation comes at


implementation level.

If we talk in terms of coding perspective, public fields show abstraction and private
fields show encapsulation.
4. What is virtual and override
The Virtual keyword is used for generating a virtual path for its derived
classes on implementing method overriding. The Virtual keyword is used
within a set with an override keyword

The Override keyword is used in the derived class of the base class in order
to override the base class method.

5. What is abstraction
 Abstraction is a concept of showing necessary information to the outside
world.

 Encapsulation is a concept of hiding unnecessary information from the


outside world.
 Abstraction comes at design level whereas Encapsulation comes at
implementation level.

If we talk in terms of coding perspective, public fields show abstraction and private
fields show encapsulation.

6. Can we have constructor to abstract class.


Yes, we can have constructor in Abstract class and we can call this
constructor from derived class.
7. What is generic
Generics allow us to design classes and methods decoupled from the data
types.
Which avoid boxing and unboxing operations and offers better performance.
List<T>, Dictionary<T>, Stack<T>, Queue<T> are few examples of generic
collections classes

8. What are the SOLID principle and can you please explain LSP
Solid is an acronym S-Single Responsibility Principle, O-Open Closed Principle,
L-Liskow Substitution Principle, I-Interface Segregation Principle, D-Dependency
Inversion Principle.

If any module is using a Base class then the reference to that Base class can be
replaced with a Derived class without affecting the functionality of the module.

For example, the father is a teacher whereas his son is a doctor. So here, in this
case, the son can’t simply replace his father even though both belong to the same
family.

9. Write program to arrange the numbers in ascending orders


INPUT: 4,3,5,8,9,2,1,
Output: 1,2,3,4,5,8,9

using System;
using [Link];
class Program
{
static void Main()
{
int[] numbers = { 4, 3, 5, 8, 9, 2, 1 };

// Sort the array in ascending order


[Link](numbers);

// Print the sorted array


[Link]("Output: " + [Link](",", numbers));
}
}

[Link] program to find out the missing number


InputPut: 10,20,30,50,60,70,80,90
OutPut: 40

using System;
using [Link];

class Program
{
static void Main()
{
int[] numbers = { 10, 20, 30, 50, 60, 70, 80, 90 };
int missingNumber = FindMissingNumber(numbers);
[Link]($"The missing number is: {missingNumber}");
}

static int FindMissingNumber(int[] numbers)


{
int difference = numbers[1] - numbers[0]; // Assuming the sequence has
a constant difference

for (int i = 1; i < [Link]; i++)


{
if (numbers[i] - numbers[i - 1] != difference)
{
return numbers[i - 1] + difference;
}
}

// Return -1 if no missing number is found


return -1;
}
}

[Link] the string


Input Put : Hello Word
OutPut :droWolleH

using System;

namespace LogicalPrograms

class Program

static void Main(string[] args)

[Link]("Enter a String : ");

string originalString = [Link]();


char[] stringArray = [Link]();

[Link](stringArray);

string reverseString = new string(stringArray);

[Link]($"Reverse String is : {reverseString} ");

[Link]();

[Link] the String character


Input : Hello Word
OutPut : Word Hello

using System;

class Program
{
static void Main()
{
string input = "Hello Word";
string output = ReverseWords(input);
[Link](output);
}

static string ReverseWords(string input)


{
// Split the input string into words
string[] words = [Link](' ');

// Reverse the array of words


[Link](words);

// Join the words back into a single string


string result = [Link](" ", words);

return result;
}
}

[Link] is the life cycle in Angular?

[Link] is a Singleton class and its purpose? - Please share the syntax for
Singleton design pattern. –
Singleton design pattern ensures a class has only one instance in the program
and provides a global point of access to it. A singleton is a class that only
allows a single instance of itself to be created and usually gives simple
access to that instance.

public sealed class Singleton


{
private static Singleton instance = null;

private Singleton()
{
}

public static Singleton Instance


{
get
{
if (instance == null)
{
instance = new Singleton();
}
return instance;
}
}
}

[Link] have you used the seal keyword?


The Sealed Class is used for the restricted inheritance feature of object-
oriented programming. Once the sealed class has been defined, this class
cannot be inherited, but we can create an instance to call the function.

[Link] is the use of static read-only lazy?


static-read-only is specially used if the type of the field is not allowed in a
const declaration, or when the value is not known at compile time.
[Link] is the difference between where can and where yes?
WHERE clause can be used with – Select and Update statements, whereas
HAVING clause can only be used with the Select statement.
WHERE filters rows before aggregation (GROUPING) whereas HAVING
filters groups after the aggregations are performed.
Aggregate functions cannot be used in the WHERE clause, unless it is in a
sub query contained in a HAVING clause whereas aggregate functions
can be used in HAVING clause.

[Link] is the difference between function and stored procedure?

- Store procedures are used for business logic (Insert, Update, Delete on
Records) whereas Functions are used for computational logic (Calculations).
- Store procedures cannot call in select statements whereas Functions can call
in select statements.
- We can do error handling in Stored procedures whereas we can’t do error
handling in Functions.
- We can implement transactions in Stored procedures whereas we can’t
implement transactions in Functions.
- We can create temporary tables inside Stored procedure whereas we can’t
create temporary tables inside Functions.
- We need not to write a return statement in Stored Procedure whereas it is
compulsory to write a return statement inside a Function.
- Stored procedure can call Stored procedure, Store procedure can call
Function whereas Function can call Function but Function cannot call Stored
procedure.

19. What is a trigger?


Triggers are the block of statements and it automatically gets fired against
the command, against the action with whom we are created that triggered.
We have different types of triggers, basically DML, DDL triggers and
triggers are very helpful if we want to execute some query without actually
writing them and without actually calling them.

[Link] is the use of using keywords?


It makes all the classes, interfaces and abstract classes and their methods and
properties available in the current page

21. What role are you looking for?

[Link] is the life cycle in [Link]?

Angular Interview Question:


1. What is pipe
2. What is component and module
3. What are the directives
4. What is services and DI
5. What is selector and template?
6. Lifecycle of Angular
7. What is databinding
8. How we can transfer the data from one component to another component
9. How does an Angular application work?
[Link] was Angular introduced?
[Link] are the advantages of Angular over other frameworks?
[Link] are the differences between AngularJS and Angular?
[Link] is AOT compilation in Angular?
[Link] the ways to achieve data binding in Angular.
[Link] are decorators and annotations?
[Link] are Angular services?
[Link] do promises and observables differ in Angular?
[Link] is the purpose of ngOnInit?
[Link] do you use ngFor within a tag?
[Link] are template-driven and Reactive forms in Angular?
[Link] is Bootstrap in Angular?

C# Interview Question

1. What is C#? What is C# used for?


C# is widely used for developing desktop applications, web applications and
web services. It is used in creating applications of Microsoft at a large scale.

2. What is an object in C#?


An object is basically a block of memory that has been allocated and
configured according to the blueprint

3. What is method overloading?


Method overloading is a compile time polymorphism because at compile time
only it is known that which overloaded method will get invoked on execution.

4. What is managed and unmanaged code in C#?


Managed code is executed within the . NET runtime environment, while
Unmanaged Code is executed outside of this environment.

5. What are the different types of comments in C#?


Single Line Comments ( // )
Multi Line Comments ( /* */ )
XML Comments ( /// )
6. Define boxing and unboxing in C#
Converting a value type to a reference type is called boxing in C# and
converting a reference type to a value type is called unboxing in C#.

7. What are circular references in C#?

Circular reference occurs when two or more interdependent resources cause


lock condition. This makes the resource unusable.

To handle the problem of circular references in C#, you should use garbage
collection. It detects and collects circular references. The garbage collector
begins with local and static and it marks each object that can be reached
through their children.

8. What does partial class mean in C#?

9. What are the features of C# language?

10. How is C# different from the C programming language?


C# is an object oriented language. C, meanwhile, is not, and therefore does
not have built-in support for classes or other OOP concepts.

11. Explain the evolution history of C#


12. What is Common Language Runtime (CLR)?

The Common Language Runtime (CLR) is a crucial component of


Microsoft's .NET framework. It serves as the execution engine for .NET
applications, providing a runtime environment that manages code execution. Here
are some key functions and features of the CLR:

1. Memory Management: The CLR handles the allocation and release of


memory for applications, including garbage collection, which automatically
frees up memory used by objects that are no longer needed.
2. Security: The CLR enforces code access security (CAS), ensuring that code
executes with the appropriate permissions and protects the system from
malicious code.
3. Exception Handling: The CLR provides a structured exception handling
model, enabling developers to write robust error-handling code.
4. Just-In-Time (JIT) Compilation: The CLR compiles Intermediate
Language (IL) code into native machine code just before execution,
optimizing performance.
5. Type Safety: The CLR enforces strict type safety, preventing type errors
that could lead to application crashes or security vulnerabilities.
6. Interoperability: The CLR allows .NET applications to interact with COM
components and other native code, enabling integration with existing
systems.
7. Debugging and Profiling: The CLR provides extensive support for
debugging and profiling, helping developers identify and fix issues in their
code.

13. What are indexers in C# .NET?

14. What is the JIT compiler process in C#?


Just In Time or JIT Compilation is the process of taking those binaries of
the Intermediate Language and converting them to native instructions that
are understood by the machine.

15. What are the types of classes in C#?


Partial,Abstract,Sealed,static class

16. What is Garbage Collection in C#?


17. Garbage Collector is provided by garbage CLR. Garbage collector is
responsible for memory management .It is run automatically and we don't
have control on it. But if we want to call a garbage collector explicitly, we
can also call it explicitly. But Microsoft does not recommend calling garbage
collectors explicitly.
SQL Interview Question

1. What is the difference between CHAR and VARCHAR2 datatype in


SQL?
Char datatype is used to store character strings of fixed length. Varchar
datatype is used to store character strings of variable length.

2. What do you mean by data definition language?

3. What is the view in SQL?


4. A view is nothing more than a saved SQL query. A view can also be
considered as a virtual table. When we try to retrieve data from the view, the
data is actually retrieved from the underlying base tables. So, a view is just a
virtual table; it does not store any data, by default. However, when we create
an index on a view, the view gets materialized. This means, the view is now
capable of storing data. In SQL server, we call them Indexed views.

5. What is the primary key?


Prmary key is used for uniqueness .for table there is a only one primary
key .It does not provide null value in the table.

6. What is a Default constraint?


The DEFAULT constraint is used to set a default value for a column.

7. What are all types of user-defined functions?

8. What is a stored procedure?


9. A stored procedure is a group of T-SQL (Transact SQL) statements. If we
have a situation, where we can write the same query again and again then we
can save that specific query as a stored procedure and call it just by its name.

10. What are aggregate and scalar functions?


The Aggregate Functions in SQL perform calculations on a group of values
and then return a single value Sum(), Max()First(),
The Scalar Functions in SQL are used to return a single value from the given
input value. Ucase(),Lcase(),

11. What are Union, minus, and Interact commands?


Union are used to combine the result set of two select queries,
The minus operation between two selections returns the rows that are
present in the first selection but not in the second selection.
The intersection operation between two selections returns only the common
data sets or rows between them.

12. What is a T-SQL?

13. What is SQL injection?

14. Can we disable a trigger? If yes, how?

What is the difference between BETWEEN and IN operators in SQL?


15.
The BETWEEN operator is utilized to compare two values inside a range,
whereas the IN operator is utilized to compare a value with a set of values.

16. What is the difference between primary key and unique constraints?
the UNIQUE constraint allows for one NULL value, but the PRIMARY
KEY does not allow NULL values.

17. What is a join in SQL? What are the types of joins?


A SQL Join is used to fetch or combine data (rows or columns) from two or
more tables based on the defined conditions.
1. Inner Join / Simple Join
2. Left Outer Join / Left Join
3. Right Outer Join / Right Join
4. Full Outer Join
5. Cross Join
18. What is the On Delete cascade constraint?

19. What are all the different attributes of indexes?


Clusterd and non clustered indexers

20. What is the difference between Cluster and Non-Cluster Index?

21. What is Case WHEN in SQL?

1. Reverse a String

csharp
Copy code
using System;

namespaceInterviewQuestions
{
classProgram
{
staticvoidMain(string[] args)
{
[Link]("Enter a string:");
string input = [Link]();
string reversed = ReverseString(input);
[Link]($"Reversed string: {reversed}");
}

staticstringReverseString(string s)
{
char[] charArray = [Link]();
[Link](charArray);
returnnewstring(charArray);
}
}
}

2. Check if a Number is Prime

csharp
Copy code
using System;

namespaceInterviewQuestions
{
classProgram
{
staticvoidMain(string[] args)
{
[Link]("Enter a number:");
int number = [Link]([Link]());
boolisPrime = IsPrime(number);
[Link]($"{number} is {(isPrime ?"a prime number" :"not a prime
number")}");
}

staticboolIsPrime(int number)
{
if (number <= 1) returnfalse;
for (int i = 2; i<= [Link](number); i++)
{
if (number % i == 0) returnfalse;
}
returntrue;
}
}
}

3. Fibonacci Sequence

csharp
Copy code
using System;
namespaceInterviewQuestions
{
classProgram
{
staticvoidMain(string[] args)
{
[Link]("Enter the number of Fibonacci terms:");
int n = [Link]([Link]());
for (int i = 0; i < n; i++)
{
[Link](Fibonacci(i));
}
}

staticintFibonacci(int n)
{
if (n <= 1) return n;
returnFibonacci(n - 1) + Fibonacci(n - 2);
}
}
}

4. Palindrome Checker

csharp
Copy code
using System;

namespaceInterviewQuestions
{
classProgram
{
staticvoidMain(string[] args)
{
[Link]("Enter a string:");
string input = [Link]();
boolisPalindrome = IsPalindrome(input);
[Link]($"{input} is {(isPalindrome ?"a palindrome" :"not a
palindrome")}");
}

staticboolIsPalindrome(string s)
{
int left = 0;
int right = [Link] - 1;
while (left < right)
{
if (s[left] != s[right]) returnfalse;
left++;
right--;
}
returntrue;
}
}
}

5. Find the Largest Number in an Array

csharp
Copy code
using System;

namespaceInterviewQuestions
{
classProgram
{
staticvoidMain(string[] args)
{
int[] numbers = { 3, 5, 7, 2, 8 };
int largest = FindLargestNumber(numbers);
[Link]($"The largest number is {largest}");
}

staticintFindLargestNumber(int[] numbers)
{
int max = numbers[0];
foreach (int number in numbers)
{
if (number > max)
{
max = number;
}
}
return max;
}
}
}

6. Sum of Digits in a Number

csharp
Copy code
using System;

namespaceInterviewQuestions
{
classProgram
{
staticvoidMain(string[] args)
{
[Link]("Enter a number:");
int number = [Link]([Link]());
int sum = SumOfDigits(number);
[Link]($"Sum of digits: {sum}");
}

staticintSumOfDigits(int number)
{
int sum = 0;
while (number != 0)
{
sum += number % 10;
number /= 10;
}
return sum;
}
}
}

7. Convert Binary to Decimal

csharp
Copy code
using System;

namespaceInterviewQuestions
{
classProgram
{
staticvoidMain(string[] args)
{
[Link]("Enter a binary number:");
string binary = [Link]();
intdecimalNumber = Convert.ToInt32(binary, 2);
[Link]($"Decimal number: {decimalNumber}");
}
}
}

8. Count Vowels in a String

csharp
Copy code
using System;

namespaceInterviewQuestions
{
classProgram
{
staticvoidMain(string[] args)
{
[Link]("Enter a string:");
string input = [Link]();
int count = CountVowels(input);
[Link]($"Number of vowels: {count}");
}

staticintCountVowels(string s)
{
int count = 0;
string vowels = "aeiouAEIOU";
foreach (char c in s)
{
if ([Link](c))
{
count++;
}
}
return count;
}
}
}

9. Check if a Year is a Leap Year

csharp
Copy code
using System;

namespaceInterviewQuestions
{
classProgram
{
staticvoidMain(string[] args)
{
[Link]("Enter a year:");
int year = [Link]([Link]());
boolisLeapYear = IsLeapYear(year);
[Link]($"{year} is {(isLeapYear ?"a leap year" :"not a leap year")}");
}

staticboolIsLeapYear(int year)
{
return (year % 4 == 0&& year % 100 != 0) || (year % 400 == 0);
}
}
}

[Link] Calculator

csharp
Copy code
using System;

namespaceInterviewQuestions
{
classProgram
{
staticvoidMain(string[] args)
{
[Link]("Enter first number:");
double num1 = [Link]([Link]());
[Link]("Enter operator (+, -, *, /):");
char op = [Link]()[0];
[Link]("Enter second number:");
double num2 = [Link]([Link]());

double result = Calculate(num1, num2, op);


[Link]($"Result: {result}");
}

staticdoubleCalculate(double num1, double num2, char op)


{
switch (op)
{
case'+':
return num1 + num2;
case'-':
return num1 - num2;
case'*':
return num1 * num2;
case'/':
return num1 / num2;
default:
thrownewArgumentException("Invalid operator");
}
}
}
}

L1 Reviewer comments:

You might also like