Compiled technical questions for interview (tcs , Infosys , Accenture )
1. What are the basic OOPs principles?
Answer:
The four main principles of OOP are:
• Encapsulation: Binding data and code together. Example: A class in Java encapsulates
variables and methods.
• Inheritance: One class inherits the properties of another. Example: A Dog class can inherit
from Animal.
• Polymorphism: One function behaves differently based on context. Example: Function
overloading or method overriding.
• Abstraction: Hiding internal details and showing only the functionality. Example: Using
abstract classes or interfaces.
2. Differentiate between C, C++, and Java
Answer:
C is a procedural programming language, which means it follows a top-down approach and focuses
on functions and procedures. It is close to hardware and is often used for system-level programming
like operating systems and embedded systems. C does not support object-oriented programming
concepts such as classes or inheritance.
C++ was developed as an extension of C and supports both procedural and object-oriented
programming (OOP). It introduces features like classes, objects, inheritance, polymorphism, and
encapsulation, allowing for code reusability .
Java, on the other hand, is a fully object-oriented programming language . Java runs on the Java
Virtual Machine (JVM), which makes it platform-independent—meaning you can write code once
and run it anywhere. Java also has automatic garbage collection, which helps manage memory
efficiently.
In summary, C is good for low-level programming, C++ adds object-oriented features to C, and Java is
a high-level, platform-independent OOP language designed for building large, secure, and portable
applications.
3. Program to check if a number is a palindrome (in C)
#include <stdio.h>
int main() {
int num, reversed = 0, remainder, original;
printf("Enter a number: ");
scanf("%d", &num);
original = num;
while(num != 0) {
remainder = num % 10;
reversed = reversed * 10 + remainder;
num /= 10;
if(original == reversed)
printf("Palindrome");
else
printf("Not a Palindrome");
return 0;
4. Difference between compiler and interpreter
Answer:
• Compiler: Translates the entire program into machine code at once. Example: C, C++.
• Interpreter: Translates one line at a time and executes. Example: Python.
• Main Difference: Compiler is faster for execution; interpreter is better for debugging.
5. What is a database? What are primary and foreign keys?
Answer:
• A database is a collection of organized data.
• A primary key uniquely identifies each record in a table (e.g., Roll No in a Student table).
• A foreign key is a field in one table that links to the primary key of another (e.g., Student's
CourseID referencing Course table).
6. What is normalization?
Answer:
Normalization is the process of organizing data to reduce redundancy and improve integrity.
It involves splitting a large table into smaller ones and linking them via relationships.
• 1NF: Atomic values (no repeating groups)
• 2NF: No partial dependency
• 3NF: No transitive dependency
7. What are the different data types in C or Java?
Answer:
In C:
• int, float, char, double, void
In Java:
• Primitive: int, float, char, boolean, double, byte, short, long
• Non-primitive: Arrays, Strings, Objects
8. Explain SDLC. Which model for a college project?
Answer:
SDLC stands for Software Development Life Cycle. The main phases are:
1. Requirement Gathering
2. Design
3. Implementation
4. Testing
5. Deployment
6. Maintenance
For a college project, I would choose the Waterfall model as it's simple, linear, and fits small-scale
projects with clear requirements.
9. Fibonacci series using recursion
#include <stdio.h>
int fibonacci(int n) {
if(n <= 1)
return n;
return fibonacci(n-1) + fibonacci(n-2);
int main() {
int n, i;
printf("Enter number of terms: ");
scanf("%d", &n);
for(i = 0; i < n; i++) {
printf("%d ", fibonacci(i));
return 0;
10. Difference between stack and queue with real-life examples
Answer:
• Stack: Follows LIFO (Last In First Out).
Example: Stack of plates – the last plate placed is the first to be removed.
• Queue: Follows FIFO (First In First Out).
Example: A line at a ticket counter – the first person in line is served first.
11. What is the Agile Model?
Answer .
● It is a type of Rapid Application Development.
● Testing is frequently done in conjunction with the development phase.
● It follows the concept of consistent growth during the project itself.
● Sprints are used to break down the projects.
12. What is the use of a constructor?
Answer :
A constructor is a special member function of a class with the same name as the class name.
● The constructor name has the same name as the class name
● Automatically calls when an object is created for the class.
● It can be defined inside or outside the class definition.
● More than one constructor can be declared inside a class with different parameters.
13. What is the difference between Abstract Class and Interface?
Answer 4.
Abstract Class vs Interface (Java)
Feature Abstract Class Interface
Can have abstract + concrete
Methods Only abstract (Java 7), + default/static (Java 8+)
methods
Feature Abstract Class Interface
Constructor
Allowed Not allowed
s
Variables Instance variables allowed Only public static final (constants)
Inheritance Single inheritance only Multiple inheritance supported
Use Case For common base with shared code For defining a contract
14. What is the difference between list and tuple in python?
List Tuple
The list is mutable. Tuples are immutable.
Enclosed in square brackets []. Enclosed in simple brackets().
Prone to errors. Not prone to errors.
Consumes more memory. Consumes less memory.
Creating a list is a slower process as it needs two memory blocks to be accessed. Creating a tuple is faster than the list.
15. What is Pass and Break statement in Python?
Answer :
Pass:
● Similar to its name, it does nothing.
● It is used to fill in code initially that can be used in the future.
● It is similar to the null operator.
● Used for empty control statements, functions, and classes.
Break:
● It is used to terminate the loop in which it is present.
● It terminates only those loops which contain a break loop.
16. What are the different types of sorting?
Answer :
The sorting algorithm arranges the elements of a list or array in a specific order. There are different
sorting algorithms that can be used to perform the sorting operation.
● Selection Sort Algorithm
● Bubble Sort Algorithm
● Heap Sort
● Merge Sort Algorithm
● Quicksort Algorithm
● Insertion Sort Algorithm
In the insertion sort algorithm, the 1st element is taken and is considered to be sorted. Then, the
second element is considered and is compared with the key elements taken and is integrated until
the array is not sorted.
17. What is the use of the JOIN clause in SQL?
Answer:
JOIN is used to retrieve data from multiple tables based on a related column between them.
Types of JOINs:
• INNER JOIN: Returns records that have matching values in both tables.
• LEFT JOIN: Returns all records from the left table and matched records from the right.
• RIGHT JOIN: Opposite of LEFT JOIN.
• FULL JOIN: Returns all records when there is a match in either table.
Example:
SELECT [Link], [Link]
FROM Customers
INNER JOIN Orders ON [Link] = [Link];
18. What are the different types of software testing?
Answer:
1. Unit Testing – Testing individual components (e.g., functions, methods).
2. Integration Testing – Testing combined parts to check data flow.
3. System Testing – Testing the complete application.
4. User Acceptance Testing (UAT) – Conducted by end users to validate the solution.
5. Regression Testing – Ensures new changes don’t affect existing functionality.
Accenture may expect awareness of automation testing tools like Selenium or manual testing
methods.
19. What is a deadlock in an Operating System?
Answer:
A deadlock is a situation in multitasking where two or more processes are blocked forever, waiting
for each other to release resources.
Example:
Process A holds Resource 1 and waits for Resource 2.
Process B holds Resource 2 and waits for Resource 1.
Deadlock Conditions:
• Mutual exclusion
• Hold and wait
• No preemption
• Circular wait
Deadlock Handling:
• Avoidance
• Prevention
• Detection and recovery
20. What programming languages and technologies have you worked with?
Answer:
As a BCA student, I’ve worked with:
• C and C++ – For foundational programming and logic building.
• Java – For Object-Oriented Programming and desktop applications.
• Python – For scripting, basic automation, and data analysis.
• HTML, CSS, JavaScript – For front-end web development.
• SQL (MySQL) – For database management and querying.
• Basics of DBMS, OS, and Computer Networks
I'm also familiar with tools like VS Code, NetBeans, and basic Git operations.