You are on page 1of 14

Object Oriented Analysis and Design
1. Interface vs abstract class.
Every single Method declared in an Interface will have to be implemented in the subclass. Only Events,
Delegates,and Methods can exist in a Interface. A class can implement multiple Interfaces.
Abstract Class:
Only Abstract methods have to be implemented by the subclass. An Abstract class can have normal
methods with implementations. Abstract class can also have class variables beside Events, Delegates,
Properties and Methods. A class can only implement one abstract class only due non-existence of Multi-
1. Variables declared in a Java interface is by default final. An abstract class may contain non-final variables.
2. Members of a Java interface are public by default. A Java abstract class can have the usual flavors of class
members like private, protected, etc.
3. In comparison with java abstract classes, java interfaces are slow as it requires extra indirection.
2. Virtual vs pure virtual function
pure virtual functions have no body (the function must be implemented in child classes)

virtual functions have a body (the function may be re implemented in child classes, but it isn't required).

Any class that has 1 or more pure virtual functions are "abstract". Abstract objects cannot be instantiated -- you
can only instantiate its child classes.
3. Diamond Problem.
The "diamond problem" (sometimes referred to as the "deadly diamond of death") is an ambiguity that arises when
two classes B and C inherit from A, and class D inherits from both B and C. If D calls a method defined in A (and
does not override the method), and B and C have overridden that method differently, then from which class does it
inherit: B, or C?
4. Multiple Inheritance in C++ and jAVA.
C++ support multiple inheritance while java doesnot.
5. Diff b/w inheritance and association.
Reusability in inheritance. In association we can make many to many relation while
inheritance only 1-m
6. What we can achieve with association but not with inheritance.
With association we can have many to many relation this cannot be achieved with
7. Give example of composition from the room you are giving interview in?
Building and the roomor room and the wall

8. Difference between assosciation,composition and aggregation.
Association is a relationship where all object have their own lifecycle and there is no owner. Lets take an
example of Teacher and Student. Multiple students can associate with single teacher and single student
can associate with multiple teachers but there is no ownership between the objects and both have their
own lifecycle. Both can create and delete independently.
Aggregation is a specialize form of Association where all object have their own lifecycle but there is
ownership and child object cannot belongs to another parent object. Lets take an example of Department
and teacher. A single teacher cannot belongs to multiple departments, but if we delete the department
teacher object will not destroy. We can think about has-a relationship.
Composition is again specialize form of Aggregation and we can call this as a death relationship. It is a
strong type of Aggregation. Child object does not have their lifecycle and if parent object deletes all child
object will also be deleted. Lets take again an example of relationship between House and rooms. House
can contain multiple rooms there is no independent life of room and any room cannot belongs to two
different house if we delete the house room will automatically delete.

9. Give real life example of polymorphism (no example from text book).
We behave differently in front of elders, and friends. A single person is behaving differently
at different time.

10. Why inheritance give real life example where the concept helps.
11. Difference between abstract class and template.
We cannot make object of abstract class while we can make an object in template
12. Different between struct and assosciation.
Totally different things..define both
13. Is Virtual class or function.
14. What is interface?
Every single Method declared in an Interface will have to be implemented in the subclass. Only Events,
Delegates, and Methods can exist in a Interface. A class can implement multiple Interfaces.

15. What is 3 tier architecture?
Client layer business logic layer->database layer
16. What is meant by structure?
Every single Method declared in an Interface will have to be implemented in the subclass. Only Events,
Delegates, and Methods can exist in a Interface. A class can implement multiple Interfaces.

17. Give example of Abstract from real life no textbook example
In the game of chess the piece class is abstract with move method and all the
pieces.king quen rook implements the function move according to how they can

Software Engineering
1. Difference between data encapsulation and abstraction and data hiding?
Encapsulation means to protect sensitive information in an object by making members protected or
private in a class. The user then has to use functions to change the state of the object,
Data hiding is an extreme version of encapsulation where you not only don't want the user to access
the data members, but you also don't even want them to be able to see what they are. This is typically
accomplished by using a void pointer or a forward declared struct pointer as the class data.
2. What is the difference between instance and object?
A class defines an object. Object is something that can represent something in the real world. When you
want the object to actually represent something in the real world that object must be instantiated.
Instantiation means you must define the characteristics (attributes) of this specific object, usually through a

3. Why do you need abstraction?
To make things simple. Xada complexity main na jaya jae
It gives you a blueprint to follow to while implementing the details. Abstraction reduces the complexity by hiding
low level details.
4. Coupling and cohesion?
An indication of the strength of interconnections between program units.
Highly coupled have program units dependent on each other. Loosely coupled are made up of units that
are independent or almost independent.
Measure of how well module fits together.
A component should implement a single logical function or single logical entity. All the parts should
contribute to the implementation.

Operating Systems
1. Advantages of thread and problems associated with them.
Aik thread ruk jae tou baqi process p effect nai parta kaam modules main hojata.. but resources divide hojate hain n memory b zada
2. How you can prevent deadlocks.
3. difference between threads and deadlocks
Threads introduce debugging issues such as race conditions and deadlocks. ... is
unpredictable values of variables that are shared between multiple threads.
Deadlocks tb atay jub 2 threads aik hi resourse k liye wait kar rahi hn..

Web Programming

General Questions

1. You have three variables say x,y and z. All are equal to 0. Apply any mathematical function to make them 6. (No number used).
May be using ascii values
2. 8 ball problem.
3. At the moment time is 3 pm what will be angle between hour and minute needle at 3.15
The time is 3:15, i.e. 25% of the time between 3 and 4 has passed. The hour-hand should, by
simple mechanical logic, have moved 25% of its total distance between 3 and 4.

The total angle the hand covers is 360%, so the angle covered between 3 and 4 should be
360/12 = 30 degrees.

The minute hand is smack on 3, and the hour hand is a quarter of 30 degrees further on. The
angle made between them is thus 30*1/4 = 7.5 degrees.

5. There are 3 containers of 3,4 nd 5 kg. They can only be measured if they are full. 4 and 5 kg are full. 3 kg container is empty. Question is
"Bring 3 kg water in the 5 kg container". (Hint after 15 mins: You can empty 3 kg bucket at any time.)
6. How to test a keyboard(IMP) check the keyboard company check the keyboard category i.e normal keyboard or multimedia keyboard check the total no of keys in that keyboard check the keyboard type i.e normal or PS/2 check the keyboard color i.e white or black check default NumLock should be in on condition
7.Default the caps lock and scroll lock should be in off condition check the keyboard wire length
with regards,
Pazhani.G check all keys are working properly or not

7. How to test a Pen(IMP)
1. Dimension of the pen,
2. Color of the pen,
3. GUI testing: logo of the pen maker,
4. Load testing
4.1 Total length that pen can write,
4.2 Strength of the nib,
5. Usability testing: grip of the pen.
6. Against the surface it can write.
7. Hanger provided in the cap,
8. How to guess outside temperature while sitting in your office with no windows(IMP)
9. Design an alarm clock for def people(IMP)
10. Design an alarm clock for def and normal people(IMP)
For 9
and 10

use vibration and bright lights to wake them up, u can use through smell their favourite food
11. What is good code(IMP)
12. How make your code good(IMP)
Same answer for 11and 12
Start with a good design. Update the design documents regularly. Create additional design
documents before adding major new features or functionality.
The program under development should be at all times functioning. The development
process consists of adding new functionality without breaking existing functionality.
Work has to be divided into small incremental steps that can be typically accomplished
and code-reviewed in one day. Even large-scale rewrites should be made incremental.
13. If 10 peoples handshake each other,total handshake?
45. Each person shakes the hand of 9 other people. So there are a total of 9*10 handshakes that
occur. However, it takes 2 people to shake hands. Each person is effectively contributing 1/2 of a
handshake and since there are 2 people, 2*1/2 = 1 handshake. So there are 9*10/2 = 45 handshakes
that occur. The formula is n*(n-1)/2

What is serialization?
Via Java Serialization you can stream your Java object to a sequence of
byte and restore these objects from this stream of bytes. To make a Java
object serializable you implement the interface. This is
only a marker interface which tells the Java platform that the object is
Delete a columns
The ALTER TABLE statement is used to add, delete, or modify columns in an existing
To add a column in a table, use the following syntax:
ALTER TABLE table_name
ADD column_name datatype

To delete a column in a table, use the following syntax (notice that some database
systems don't allow deleting a column):
ALTER TABLE table_name
DROP COLUMN column_name
To change the data type of a column in a table, use the following syntax:

ALTER TABLE table_name
ALTER COLUMN column_name datatype

What is static function and non-statics?

A static method belongs to the class itself and a non-static (aka instance) method belongs to each
object that is generated from that class. If your method does something that doesn't depend on the
individual characteristics of its class, make it static (it will make the program's footprint smaller).
Otherwise, it should be non-static.

Class Foo {
int i;

public Foo(int i) {
this.i = i;

public static String method1() {
return "An example string that doesn't depend on i (an instance

public int method2() {
return this.i+1; // Depends on i

What are turnaround time and response time?
Turnaround time is the interval between the submission of a job and its completion. Response time
is the interval between submission of a request, and the first response to that request.

JAVA is independent
Bcz it use the WORA (Write once and run anywhere) principle.JAVA programming language is
designed to run under OS and that is main advantage of it.
What is the difference between a process and a thread
Both processes and threads are independent sequences of execution. The typical difference is
that threads (of the same process) run in a shared memory space, while processes run in
separate memory spaces.

Data Structures

1. Find mid of a linked list (Singly) in O(n)
We have done.. by taking two pointers
2. Find loop in List (singly) in O(n)
Double loop laga lo.. n hur aik ko puri list main daikho.. but O(n) main kaisay hota dnt know
3. Delete the node on which you have iterator pointing, without using any other pointer.
Usky next ko agly ka next buna do
4. use arrays to tell whether a string is palindrom or not.
Simple phle leght nikalo n then i=0 and j=strlen kar k I and j ko match karte jao
5. why destructor is not over loaded?

6. What is difference between overloading and overriding?
Overriding main parameters and function definition same htiu.. jub k in overloading parmetrs r diff with same
function name
7. Why we use data structures?
8. Invert the string " this is my string" and print it.
9. Given a grid(matrix), print all possible paths from (0,0) to (M,N). Legal moves are right and down.(IMP)
10. Write a function to type cast float to int(IMP)
11. write a function to search a character from a character pointer(IMP)
12. write a function which takes an array and returns an int value which is having min distance in its repeated

13. write a function that takes a string and print words in reverse order (IMP)

14. Solution of Josephus Problem and it's complexity


1. query to find 3rd max from a table
Select max(sal)
from table t1
where N (select max(sal)
from table t2
where t2.sal > t1.sal)

SELECT DISTINCT(column_name)
FROM table_name
ORDER BY column_name DESC limit N-1,1;
where N represents the nth highest salary ..

2. why we return 0 in c++ in main , y not we return 5 or 10??
ans) 0 means completion without any abort if we write 5 or 10 program still runs successfully but in actual it will
abort in the real sense.

3. how we can run our program in c++ from some other function than main?
ans) by setting the linker to require function from cmd

4. what is the probability that u always pick out same ball from a bag having infinite balls?
ans) i think cant find probability in case of infinite cnfrm me as well

5) what we should prefer more inheritence or composition
ans depends on scenerio explain both with examples

recursive algo to find 2^n by givin n
int power(int n, int e)
int product=1;
return 1;
else if(e==1)
return n;
return product=n*power(n,e-1);
For factorial and fibonacci
int fic(int n)
int product=1;
return 1;
else if(n==1)
return 1;
return product=n*fic(n-1);

int fib(int n)
int sum=0;
return 0;
else if(n==1)
return 1;
else if(n==2)
return 1;
return sum= fib(n-1) +fib(n-2);

7) what is open closed principle
open for extension close for modification

1. Database normaliztion. Why we do that? Different Normalized forms and how to go from lower normalized form
to higher ones.
2. how many types of join are there and what is theri difference.
3. what is an index ?
4. Write one single query to remove duplicate records from Database
SELECT date FROM logs group by date having count(*) >= 2
6. On which criterion do you make an attribute indexed?
7. What happens if you index all of the attributes?
8. what are the types of indexing? and which to use in what scenerio?
9. How indexing "optimizes" the search?
10. write code to demonstrate difference between Composition and Aggregation.
11. General OOAD questions, same as GVS.
12. Draw component diagram for your FYP and explain each thing in detail.

13. What is RS document? what is FS document? what contains what?(IMP)

The documentation typically describes what is needed by the system user as well as requested
properties of inputs and outputs (e.g. of the software system). A functional specification is the
more technical response onto a matching requirements document

What is done on back end when you perform indexing on table?

Can static method call non-static members of class? if yes/no then "Why"?
The only way to call a non-static method from a static method is to have an instance of the class
containing the non-static method. By definition, a non-static method is one that is called ON an
instance of some class, whereas a static method belongs to the class itself.

can we write a try block without catch block in java
Either try and catch(single or multiple)

Either try and finally

Either try , catch and finally in the same sequence.

Reverse a number (e.g -351 => -153)
public static int reverse(int number){
int reverse = 0;
int remainder = 0;
remainder = number%10;
reverse = reverse*10 + remainder;
number = number/10;

}while(number > 0);

return reverse;


What is the use of copy constructor?
Initialize at the time of decleration
Parameter passing
Return value

What will happen if i pass by value in parameter of copy constructor?
Infinite call bun jati hai, becuz copy constructor itself by value hta, and agr by value paas karain gain tou jub b value contructor call hoga
tou value bhaikne k liye b vohi constructor call hoga n phir again value bhjne k liye dbra call hoga so infinite chalta jae ga.
Why is int of 4 bytes? (depends on compiler? or c++)?
Yes , I found that size of int in turbo C was 2 bytes where as in MSVC compiler it was 4
Basically the size of int is the size of the processor registers.

What are uses of polymorphism?
In C++ templates, is memory allocated at compile time or run time?
If you created a variable of a primitive type like int, char, float inside a function. Did you
create that variable at runtime or at compile time?
You create the variable at run-time, the variable is created when the function is executed,
and is destroyed when the function is finished.
If you created an object inside a function. Did you create that object at runtime or at
compile time?
Same as above

What will happen if you dont implement a pure virtual function? run time error or compile time?
Compile time error, becuz vo class b abstract hojae gin d uska object nai bun skta.
What will happen if you dont make virtual distructors?
You would see that the dtor of the derived class is not called if you don't say virtual in the base.
given a stack abc{int a char b}; you make array of abc. if abc[0] is at 1050 whats address of abc[5]?

given a tree's root node.. tell if its balanced or not.

Time complexity of different sorting
Name Best Worst
Merge sort
Insertion sort
Bubble sort

2d to 1d array address translation.

Composition is typically "has a" or "uses a" relationship. Here the Employee class has a Person. It
does not inherit from Person but instead gets the Person object passed to it, which is why it "has a"
Person. Diamond problem does not arise using composition.
Its important to remember that one might say "Composition over inheritance" but that does not mean
"Composition always over Inheritance". "Is a" means inheritance and leads to code reuse. Employee is a
Person (Employee does not have a person)
In Java or C#, an object cannot change its type once it has been instantiated. So, if your object need
to appear as a different object or behave differently depending on an object state or conditions, then
use Composition: Refer to State and Strategy Design Patterns. If the object need to be of the same
type, then use Inheritance or implement interfaces.
Composition can be easily modeled through a foreign-key relationship between two tables, but
inheritance is much harder.
Virtual function=== simple function.. that can be override or no
Abstract or pure virtual function is like abstract function.. that has to be implemented
Disadvantages of Inheritance:
1. You can't change the implementation inherited from super classes at runtime (obviously because
inheritance is defined at compile time).
2. Inheritance exposes a subclass to details of its parent's class implementation, that's whey it's often said
that inheritance breaks encapsulation (in a sense that you really need to focus on interfaces only not
implementation, so reusing by sub classing is not always preferred).
3. The tight coupling provided by inheritance makes the implementation of a subclass very bound up with the
implementation of a super class that any change in the parent implementation will force the sub class to
4. Excessive reusing by sub-classing can make the inheritance stack very deep and very confusing too.
On the other hand Object composition is defined at runtime through objects acquiring references to other
objects. In such a case these objects will never be able to reach each-other's protected data (no encapsulation
break) and will be forced to respect each other's interface. And in this case also, implementation dependencies
will be a lot less than in case of inheritance.
One drawback to using composition in place of inheritance is that all of the methods being provided by the composed
classes must be implemented in the derived class
Composition simply means using instance variables that refer to other objects. The class House will have an instance
variable, which refers to a Bathroom object.

Difference between TRUNCATE, DELETE and DROP
The DELETE command is used to remove rows from a table. A WHERE clause can be used to only
remove some rows. If no WHERE condition is specified, all rows will be removed. After performing a
DELETE operation you need to COMMIT or ROLLBACK the transaction to make the change permanent or
to undo it. Note that this operation will cause all DELETE triggers on the table to fire.

TRUNCATE removes all rows from a table. The operation cannot be rolled back and no triggers will be
fired. As such, TRUCATE is faster and doesn't use as much undo space as a DELETE.
The DROP command removes a table from the database. All the tables' rows, indexes and privileges will
also be removed. No DML triggers will be fired. The operation cannot be rolled back.