SAP LABS INTERVIEW QUESTIONS
1)What is data abstraction and give an real life example?
2)What is inheritance and its types. explain with example?
3)what are linked list, double linked list and circular linked list?
4)Various Differences between C and C++?
5)What is stack?
6)What is TREE, why it is being used. Explain all the traversal?
7)Data structure and why do we use them. Give real life example of stack and queue?
8)To reverse a single linked NULL terminated list in a single iteration of all the nodes.
9)Difference between call by pointer and call by reference.
10)what is volatile data type in C?
11)About the static data class?
12)write a program to find middle node of a single linked NULL terminated list in a single iteration of nodes.
13)code of fibonacci using recursion.
14)WAP to check the linklist is circular (or) not?
15)Find Minimum and Maximum of an array in only one traversal.
16)Given a chessboard find the maximum number of squares present?
17)Difference between deep and shallow copy?
18)Reverse a linked list with and without using Recursion
19)Copy constructor?
20)Different types of polymorphism, the diamond problem, and how can it be avoided?
21)Questions about Virtual
22)Template classes
23)Write a program for an operator(=) such that it behaves differently for integer and character.
24)Given an array, sort the zero's from non zeros
For example
Input: 1 2 0 0 7 4 42 0 0 0 6
Output: 1 2 7 4 42 6 0 0 0 0 0
25)class hierarchy, List the number of VTables created?
26)When to use List and Vector of Standard Template Library ?
27)Given a string “I LOVE CODING”, print “CODING LOVE I”?
28)inheritance concepts, private/public/protected concepts?
29)Different versions of polymorphism, how to solve the problem of multiple inheritance.
30)What is a class and object in C++. Explain by taking an example.
31)What is static and use of it? Give a real life example where you would use it?
32)What are public, private called in C++,What is the use of them? For whom would it be useful users or developers?
33)How is Encapsulation implemented and an example?
34)What is use of inheritance?
35)Write a program to find second largest number in an array?
36)Error handling in C and C++
37)OOPS concepts, whether OOPS is used in real world also? How is it useful?
38)Operator overloading
39)Calloc vs Malloc with example
40)C (string, array, bitwise operators)
41)Array Vs Linked list
42)Dynamic and static binding
43)Virtual function in C++.
44)What is structure padding ?
45)Implement the malloc() and free() operations. Give the strategy for implementation, no coding.
46)Pure virtual function?
47)Abstract class?
48)Exception Handling?
49)What is garbage collection ?
50)What are the basic OOPS concepts ?
51)Design Patterns, Simple programs(fibonacci, linked lists, binary search tree, merge sort)
52)How to find midpoint of a linked list.
53)Some basic questions on C++ and OOPS concepts
54)Find if string is palindrome or not
55)Search for a particular string in given text
56)What is function overloading and overriding?
57)Write a code that counts the Number of objects created for a specific Class.
58)What is Exception Handling, what are types of Exception Handling and can there be user defined exception handler?
59)Mechanism of Try and Catch Block., Finally Block, What happens when there is a return statement in a catch block or in a finally block, where does the control go back?
60)Fizz-buzz. String reversal.
61)Check for duplicate digits in a number?
62) What will be the output of “printf(“%d”)”
63)Error handling in C. “errno() and perror()”
64)Implement a Queue using a stack.
65)Find sum of first n prime numbers.
66)how to find the size of structure without using sizeof operator , real time application of stack and queue
67)difference between 32bit os and 64 bit OS
68)Write a program to solve sudoku puzzle
69)Find pythagaran triplets in given array ?
70)Bubble sort vs Insertion sort
71)Time complexity vs Space complexity
72)Semaphore vs mutex
73)Process and thread
74)Multithreading
75)Paging
76)Critical section of code
77)RAM,hardisk,Cache memory
78)Memory management of OS.
79)TCP VS UDP
80)Data structures operations like adding node,deletion,reversing the node and links
*****PUZZLES IN SAP LABS INTERVIEW*****
1) “There is a room. Inside that room there are ant and sweet placed at diagonally opposite end. Find the shortest distance that ant needs to travel to get the sweet (Ants can’t fly)”.
2 )A puzzle which is “Two sand arcs which measures 7 min and 4 min each. Count 9 min using those two”.
3) A game is there, certain integers are coming randomly on screen, suppose 5 Is there on screen, if a user type 5 and press enter, the digit should vanish and the score of user should increment to 1, but if the user inputs wrong number or failed to input any number, he should get no marks. At the end he wanted me to give the output of
1)Total number of integers appeared on the screen
2)Score of user
4) A user inputs a number say 32 , and a position say 7. write a function which takes the number and sets its 7th position counting from least significant digit and then return the resultant number in decimal.
like, 32’s binary representation is 00100000 and after setting its 7th position from least significant position, the resultant number becomes: 01100000,which is 96.
I was solving it using decimal to binary conversion and then putting the result in an array and then setting the position, but he was seeming dissatisfied with it and asked me-“Can’t it be done an easy way?”. It then strike me that I can use a bitwise OR. I had to OR between the number(32 in this case) and 2^position-1(this gives a number whose 7th position is set as 1) to set the given position. He was now satisfied with it.
5) A simple puzzle to count number of squares of same size and derive a formula.
6)You have 3 baskets, one with apples, one with oranges and one with both apples and oranges mixed.Each basket is closed and is labeled with ‘Apples’, ‘Oranges’ and ‘Apples and Oranges’.However, each of these labels is always placed incorrectly.How would you pick only one fruit from a basket to place the labels correctly on all the baskets?
7)Then he asked me one puzzle-EGG-DROP-100 STAIRS puzzle(we all know). Then he asked me to code the puzzle(I used the binary search approach-easiest one. :P).
8)There is a square consisting of 4 x 4 squares. So count total number of squares and come up with a formula for no. of squares in a n x n square.
9)There are 25 horses. There are 5 tracks. So at a time, only 5 horses can be raced. What is the minimum number of races to be conducted to decide the winner?
10)Hot sunny day , a bridge with a car on it weighing 1000kg .Also bridge can weigh only 1000KG not even 1gm extra it breaks otherwise.
A crow weighing 400gm comes and sits on it what happens?
A)The bridge won't break.
When the car has travelled half of the bridge, that is 15km, the car must have used more than 300 grams of fuel. Therefore, the impact of bird's added weight will be zero literally.
B)The bridge will not break.
This is because when the bridge reaches the mid-point, it would have traveled 10km. While traveling 10km, the car would have used more than 200 grams of fuel. Thus, the weight of bird will not add much to the existing weight.
11)You with a car and three people ur lover, a old lady immediately needs to be in hospital , a best friend who needs to go to airport for a job interview in his dream company. All other people in city are busy in some strike – they cant be involved with you.
You have only one extra seat in car .Who would you pick up.
– Was able to solve it in 3rd attempt.
12)Three bulbs , three switches in another room – this was simple we all know. After solving this he tweaked problem a bit.
13)three switch three bulb problem and to identify lighter ball from given 8 ball using balance just two times.
14)There are 10 balls out of which one ball is heavier and all other balls are of equal weight , how many min measurements are required to find the heavier one?
15)Again a puzzle on weights, There are 25 machines producing 1kg weights , suddenly a machine corrupted and started producing weights measuring 999grams,Find the machine with a single measurement?
16)A window of size k is sliding from left to right in an array of size n, find the maximum number in the window at each window position.
17)Burning Rope Puzzle, Water Jug Problem, Cutting Pizza into 8 slices with 3 cuts.
18)In a 4x4 jail, there is living man in every cell. Assume there is madman in the left-down corner, and a exit in top-right corner. One night the Madman escaped from prison, killing every other men in the jail. the Madman can go up-down and left-right but not corner-wise. If the madman enters a room with a prisoner in it, then he kills the man, if there is a dead man in the room, he kills himself. How the madman esceped that night?
19)A boy goes to his grandmother’s house. There he either does yoga in the morning / plays tennis in the evening / does neither. However he does not do both on the same day. We know that 22 days he did either 1 activity. 24 mornings he did nothing. 12 evenings he did nothing. How many min days did he stay there to have done this?
20)Suppose there is a bridge with a time bomb planted on it which will explode in 17 mins. There are four persons namely A,B,C and D on one side of the bridge who need to be evacuated, who take 10 min, 5 min, 2 min and 1 min respectively. The is only one torch which needs to be carried while crossing the bridge and at most two persons can cross at a time and they take the maximum time out of the two.Suggest a way so that all of them cross the bridge before it explodes.
A)The person who takes 1 second to cross the bridge crosses with the person who takes 2 seconds. So two seconds already passed. The 1 second person goes back so now its three seconds that passed. He gives the flashlight to the person who takes 10 seconds and the person who takes 5 seconds to cross. So now its a total of 13 seconds that passed. The person who takes 2 seconds goes back and comes back with the one second person making the total time 17 seconds.
21)A person has 53 socks in a bag. 21 blue 17 red and 15 black. how many should he take to ensure there are 2 black socks in it?
1)What is data abstraction and give an real life example?
2)What is inheritance and its types. explain with example?
3)what are linked list, double linked list and circular linked list?
4)Various Differences between C and C++?
5)What is stack?
6)What is TREE, why it is being used. Explain all the traversal?
7)Data structure and why do we use them. Give real life example of stack and queue?
8)To reverse a single linked NULL terminated list in a single iteration of all the nodes.
9)Difference between call by pointer and call by reference.
10)what is volatile data type in C?
11)About the static data class?
12)write a program to find middle node of a single linked NULL terminated list in a single iteration of nodes.
13)code of fibonacci using recursion.
14)WAP to check the linklist is circular (or) not?
15)Find Minimum and Maximum of an array in only one traversal.
16)Given a chessboard find the maximum number of squares present?
17)Difference between deep and shallow copy?
18)Reverse a linked list with and without using Recursion
19)Copy constructor?
20)Different types of polymorphism, the diamond problem, and how can it be avoided?
21)Questions about Virtual
22)Template classes
23)Write a program for an operator(=) such that it behaves differently for integer and character.
24)Given an array, sort the zero's from non zeros
For example
Input: 1 2 0 0 7 4 42 0 0 0 6
Output: 1 2 7 4 42 6 0 0 0 0 0
25)class hierarchy, List the number of VTables created?
26)When to use List and Vector of Standard Template Library ?
27)Given a string “I LOVE CODING”, print “CODING LOVE I”?
28)inheritance concepts, private/public/protected concepts?
29)Different versions of polymorphism, how to solve the problem of multiple inheritance.
30)What is a class and object in C++. Explain by taking an example.
31)What is static and use of it? Give a real life example where you would use it?
32)What are public, private called in C++,What is the use of them? For whom would it be useful users or developers?
33)How is Encapsulation implemented and an example?
34)What is use of inheritance?
35)Write a program to find second largest number in an array?
36)Error handling in C and C++
37)OOPS concepts, whether OOPS is used in real world also? How is it useful?
38)Operator overloading
39)Calloc vs Malloc with example
40)C (string, array, bitwise operators)
41)Array Vs Linked list
42)Dynamic and static binding
43)Virtual function in C++.
44)What is structure padding ?
45)Implement the malloc() and free() operations. Give the strategy for implementation, no coding.
46)Pure virtual function?
47)Abstract class?
48)Exception Handling?
49)What is garbage collection ?
50)What are the basic OOPS concepts ?
51)Design Patterns, Simple programs(fibonacci, linked lists, binary search tree, merge sort)
52)How to find midpoint of a linked list.
53)Some basic questions on C++ and OOPS concepts
54)Find if string is palindrome or not
55)Search for a particular string in given text
56)What is function overloading and overriding?
57)Write a code that counts the Number of objects created for a specific Class.
58)What is Exception Handling, what are types of Exception Handling and can there be user defined exception handler?
59)Mechanism of Try and Catch Block., Finally Block, What happens when there is a return statement in a catch block or in a finally block, where does the control go back?
60)Fizz-buzz. String reversal.
61)Check for duplicate digits in a number?
62) What will be the output of “printf(“%d”)”
63)Error handling in C. “errno() and perror()”
64)Implement a Queue using a stack.
65)Find sum of first n prime numbers.
66)how to find the size of structure without using sizeof operator , real time application of stack and queue
67)difference between 32bit os and 64 bit OS
68)Write a program to solve sudoku puzzle
69)Find pythagaran triplets in given array ?
70)Bubble sort vs Insertion sort
71)Time complexity vs Space complexity
72)Semaphore vs mutex
73)Process and thread
74)Multithreading
75)Paging
76)Critical section of code
77)RAM,hardisk,Cache memory
78)Memory management of OS.
79)TCP VS UDP
80)Data structures operations like adding node,deletion,reversing the node and links
*****PUZZLES IN SAP LABS INTERVIEW*****
1) “There is a room. Inside that room there are ant and sweet placed at diagonally opposite end. Find the shortest distance that ant needs to travel to get the sweet (Ants can’t fly)”.
2 )A puzzle which is “Two sand arcs which measures 7 min and 4 min each. Count 9 min using those two”.
3) A game is there, certain integers are coming randomly on screen, suppose 5 Is there on screen, if a user type 5 and press enter, the digit should vanish and the score of user should increment to 1, but if the user inputs wrong number or failed to input any number, he should get no marks. At the end he wanted me to give the output of
1)Total number of integers appeared on the screen
2)Score of user
4) A user inputs a number say 32 , and a position say 7. write a function which takes the number and sets its 7th position counting from least significant digit and then return the resultant number in decimal.
like, 32’s binary representation is 00100000 and after setting its 7th position from least significant position, the resultant number becomes: 01100000,which is 96.
I was solving it using decimal to binary conversion and then putting the result in an array and then setting the position, but he was seeming dissatisfied with it and asked me-“Can’t it be done an easy way?”. It then strike me that I can use a bitwise OR. I had to OR between the number(32 in this case) and 2^position-1(this gives a number whose 7th position is set as 1) to set the given position. He was now satisfied with it.
5) A simple puzzle to count number of squares of same size and derive a formula.
6)You have 3 baskets, one with apples, one with oranges and one with both apples and oranges mixed.Each basket is closed and is labeled with ‘Apples’, ‘Oranges’ and ‘Apples and Oranges’.However, each of these labels is always placed incorrectly.How would you pick only one fruit from a basket to place the labels correctly on all the baskets?
7)Then he asked me one puzzle-EGG-DROP-100 STAIRS puzzle(we all know). Then he asked me to code the puzzle(I used the binary search approach-easiest one. :P).
8)There is a square consisting of 4 x 4 squares. So count total number of squares and come up with a formula for no. of squares in a n x n square.
9)There are 25 horses. There are 5 tracks. So at a time, only 5 horses can be raced. What is the minimum number of races to be conducted to decide the winner?
10)Hot sunny day , a bridge with a car on it weighing 1000kg .Also bridge can weigh only 1000KG not even 1gm extra it breaks otherwise.
A crow weighing 400gm comes and sits on it what happens?
A)The bridge won't break.
When the car has travelled half of the bridge, that is 15km, the car must have used more than 300 grams of fuel. Therefore, the impact of bird's added weight will be zero literally.
B)The bridge will not break.
This is because when the bridge reaches the mid-point, it would have traveled 10km. While traveling 10km, the car would have used more than 200 grams of fuel. Thus, the weight of bird will not add much to the existing weight.
11)You with a car and three people ur lover, a old lady immediately needs to be in hospital , a best friend who needs to go to airport for a job interview in his dream company. All other people in city are busy in some strike – they cant be involved with you.
You have only one extra seat in car .Who would you pick up.
– Was able to solve it in 3rd attempt.
12)Three bulbs , three switches in another room – this was simple we all know. After solving this he tweaked problem a bit.
13)three switch three bulb problem and to identify lighter ball from given 8 ball using balance just two times.
14)There are 10 balls out of which one ball is heavier and all other balls are of equal weight , how many min measurements are required to find the heavier one?
15)Again a puzzle on weights, There are 25 machines producing 1kg weights , suddenly a machine corrupted and started producing weights measuring 999grams,Find the machine with a single measurement?
16)A window of size k is sliding from left to right in an array of size n, find the maximum number in the window at each window position.
17)Burning Rope Puzzle, Water Jug Problem, Cutting Pizza into 8 slices with 3 cuts.
18)In a 4x4 jail, there is living man in every cell. Assume there is madman in the left-down corner, and a exit in top-right corner. One night the Madman escaped from prison, killing every other men in the jail. the Madman can go up-down and left-right but not corner-wise. If the madman enters a room with a prisoner in it, then he kills the man, if there is a dead man in the room, he kills himself. How the madman esceped that night?
19)A boy goes to his grandmother’s house. There he either does yoga in the morning / plays tennis in the evening / does neither. However he does not do both on the same day. We know that 22 days he did either 1 activity. 24 mornings he did nothing. 12 evenings he did nothing. How many min days did he stay there to have done this?
20)Suppose there is a bridge with a time bomb planted on it which will explode in 17 mins. There are four persons namely A,B,C and D on one side of the bridge who need to be evacuated, who take 10 min, 5 min, 2 min and 1 min respectively. The is only one torch which needs to be carried while crossing the bridge and at most two persons can cross at a time and they take the maximum time out of the two.Suggest a way so that all of them cross the bridge before it explodes.
A)The person who takes 1 second to cross the bridge crosses with the person who takes 2 seconds. So two seconds already passed. The 1 second person goes back so now its three seconds that passed. He gives the flashlight to the person who takes 10 seconds and the person who takes 5 seconds to cross. So now its a total of 13 seconds that passed. The person who takes 2 seconds goes back and comes back with the one second person making the total time 17 seconds.
21)A person has 53 socks in a bag. 21 blue 17 red and 15 black. how many should he take to ensure there are 2 black socks in it?