Infosys Placement Paper
Infosys Placement Paper
BY JOBHUNTER GRPS
Please note some of the key points here, example- Founder, CEO, Tag line and specially some good
points about company. They may ask you in the interview "Why Infosys?".
This written test is divided into 3 sections. The important topics for each of these sections is given as
follows:
Quant: permutations & combinations, number series, crypto math's, analytical puzzles, alligations and
mixtures, probability etc.
Reasoning: data sufficiency, data (pie / bar / tables / chart), syllogisms, blood relations, statement
reasoning etc.
Verbal: one long RC, one short RC, basic grammar, such as : fill in the blanks, antonyms + synonyms,
sentence correction, theme detection etc.
In Reasoning, there were 15 questions. You really need to brush up your skills in topics like Data
interpretation , data sufficiency, syllogism and number series to clear this section. Level of questions-not
very easy, not too difficult. Just relax your mind and start solving. Indiabix would be enough. Time limit
for this section was 25 minutes. But believe me, time constraint is not going to create any problem in
this section.
Regarding aptitude, there will be 10 questions. 5 questions will be easy, you will hardly take 10 min to
solve those 5. But the rest 5 are going to create little problem. Those will be little complex and you really
need to have some good approach to solve them. You are definitely not going to face much problems if
you have solved these chapters multiple times from R.S Aggarwal-Permutations and combinations,
probability, Numbers, Profit-loss, Time-distance . Well, this is the best book you can find in market. 1 or
2 complex problems from cryptarithmetic will be there, just google it now, it is really an easy one. Time
limit for this section-35 min.
Coming to verbal ability, here they are not only checking your knowledge in English but your patience as
well. This section is going to be little tough as compared to the above two. You really need to have a
good knowledge of Basic English grammar that you have studied in your school days, because at present
it would be difficult for you to pick up "Wren-n-Martin" and start studying tense, voice, narration
etc.(You may try if you have time and patience.) In this section you will get 40 questions which include 2
paragraphs, sentence correction, spotting errors, jumbled sentences based on basic grammar. No
synonyms and antonyms were asked. Indiabix will be good for practice. Time limit for this section-35
min
***********************************
My-jobhunter.com
***************************************
INTERVIEW QUESTIONS:
committees.
committee C.
Answer: B
together on committee C is
Answer: D
Answer: D
committee A?
Answer: C
Answer: A
coded?
A.AIDARET B.IDARA TE C.ARIADTE D.IDAATRE
Answer: D
Answer: C
Answer: D
Answer: A
coded?
Answer: C
11. How many such letter-pairs are there in the word SERVANT
having the same no. of letters left between them in the word as
Answer: A
12. How many such letter-pairs are there in the word MONKEY
the series?
Answer: A
Answer: E
Answer: A
16. Statements :
Conclusions :
Answer: D
17. Statements :
Sachin is honest
Conclusions :
I. Sachin is a boy
Answer: D
18. Statements :
Madhu is a nun
Conclusions :
Answer: D
19. Statements :
No door is wall
Conclusions :
I. No window is wall
Answer: A
20. Statements :
Conclusions :
Answer: D
you’; ”˜da na ja’ means ”˜you may come’ and ”˜na ka sa’
Answer: B
Answer: D
Explanation:
day. Now for in 47 years we have 11 leap years and 36 normal years.
9898798769876598765498765
Answer: B
after 8th July but before 12th July. Her brother correctly
father’s birthday ?
determined
Answer: B
25. Four of the following five are alike in a certain way and so
form a group. Which is the one that does not belong to that
Answer: A
26. There are 6 boys Amit, Banhid, Dhruv, Chand, Harsh and
order. The pairs want to visit movie, beach, park and play; and
two of them want to go to circus. They like different
given:
- Amit and Chand visit circus, but don't like pav-bhaji or panipuri.
respectively.
pani-puri.
a park.
Answer: A
Answer: C
Answer: B
Answer: B
Answer: B
Sol:
The pattern is
1 = 21 – 1
4 = 22 – 0
9 = 23 + 1
18 = 24 + 2
35 = 25 + 3
68 = 26 + 4
USA = 932
USSR = 9338
PEACE = 10270
P + E + A + C + E = 1 + 0 + 2 + 7 + 0 = 10
3. In a cycle race there are 5 persons named as J, K, L, M, N participated for 5 positions so that in how
many number of ways can M make always before N?
Sol:
Now M came in second. N can finish the race in 3rd, 4th or 5th position. So total ways are 3 x 3! = 18.
Shortcut:
Total ways of finishing the race = 5! = 120. Of which, M comes before N in half of the races, N comes
before M in half of the races. So 120 / 2 = 60.
Sol:
1 + I = R, So I and R are consecutive. R > I. i.e., G > R > I. and G, R, I are consecutive. Now O + T should
give carry over and O + Z also give carry over. So O is bigger number. Now take values for G, R, I as 8, 7,
6 or 7, 6, 5 etc. and do trial and error.
POINT = 98504, ZERO = 3168 and ENERGY = 101672.
So E + N + E + R + G + Y = 1 + 0 + 1 + 6 + 7 +2 = 17
5. There are 1000 junior and 800 senior students in a class. And there are 60 sibling pairs where each
pair has 1 junior and 1 senior.1 student is chosen from senior and 1 from junior randomly.What is the
probability that the two selected students are from a sibling pair?
Sol:
Therefore,1 student chosen from senior and 1 student chosen from junior
Therefore
Sol:
Observe the diagram. M = 1. S + 1 = a two digit number. So S = 1 and O cannot be 1 but 0. Also E and N
are consecutive. Do trial and error.
SEND = 9567, MORE = 1085, MONEY = 10652
SO M + O + N + E + Y = 1 + 0 + 6 + 5 + 2 = 14
7. A person went to shop and asked for change for 1.15 paise. But he said that he could not only give
change for one rupee but also for 50p, 25p, 10p and 5p. What were the coins he had ?
Sol:
8. 1, 1, 2, 3, 6, 7, 10, 11, ?
Sol:
The given pattern is (Prime number - consecutive numbers starting with 1).
1=2–1
1=3–2
2=5–3
3=7–4
6 = 11 – 5
7 = 13 – 6
10 = 17 – 7
11 = 19 – 8
14 = 23 – 9
1. A Lorry starts from Banglore to Mysore At 6.00 a.m, 7.00 a.m, 8.00 a.m.....10 p.m. Similarly another
Lorry on another side starts from Mysore to Banglore at 6.00 a.m, 7.00 a.m, 8.00 a.m.....10.00 p.m. A
Lorry takes 9 hours to travel from Banglore to Mysore and vice versa.
(I) A Lorry which has started At 6.00 a.m will cross how many Lorries.
(II) A Lorry which has started At 6.00 p.m will cross how many Lorries.
Sol:
I. The Lorry reaches Mysore by 3 PM so it meets all the Lorries which starts after 6 a.m and before 3 p.m.
So 9 lorries. Also the Lorry which starts at night 10 p.m on the previous day at Mysore reaches
Bangalore in morning 7 a.m. So it also meets that Lorry. So the Lorry which starts at 6:00 am will cross
10 Lorries.
II. The lorry which has started at 6 p.m reaches destination by 3 a.m. Lorries which start at the opposite
destination at 10 am reaches its destination at 7 pm. So all the lorries which starts at 10 am to 10 pm
meets this lorry . So in total 13.
2. GOOD is coded as 164 then BAD coded as 21.if ugly coded as 260 then JUMP?
Sol:
GOOD = (7 + 15 + 15 + 4 ) x 4 = 164
BAD = (2 + 1 + 4) x 3 = 21
Sol: Tough one as it has 10 variables in total. 4 digit number + 5 digit number = 6 digit number. So left
most digit in the answer be 1. and S = 9, a = 0. Now we have to use trial and error method.
Here E appeared 3 times, I, R, N two times each. Now E + I or E + I + 1 is a two digit number with carry
over. What could be the value of E and I here. 8 and 7 are possible. But from the second column, 8 + C
= 7 or 17 not possible. Similarly with 7 and 6. If E = 5, then the remaining value can be filled like above.
Answer is 23
(1) Number of matches played when each team plays with each other twice.
(2) Number of matches played when each team plays each other once.
Sol:
1. Number of ways that each team played once with other team =
16
2.
16
16C2 = 120
A. 190
B. 200
C. 210
D. 220
E. 225
Sol:
Formula:
15
6. 1, 11, 21, 1211, 111221, 312211, . . . . . what is the next term in the series?
Sol:
One
Then one time one, one time two and two time 1 that is = 111221
And last term is three time 1, two time 2, and one time 1 that is = 312211
So our next term will be one time 3 one time 1 two time 2 and two time 1
13112221 and so on
7. How many five digit numbers are there such that two left most digits are even and remaining are
odd.
Sol:
N = 4 x 5 x 5 x 5 x 5 = 2375
Where
8. 13_46_8_180_210_75 = 64 . Use + and – in the empty places to make the equation holds good. Take
m = number of + and n = number of – . Find m – n?
Sol:
13 – 46 – 8 – 180 + 210 + 75 = 64
m=3
n=4
m–n=–1
10. If a refrigerator contains 12 cans such that 7 blue cans and 5 red cans. In how many ways can we
remove 8 cans so that atleast 1 blue can and 1 red can remains in the refrigerator.
Sol:
Possible ways of keeping atleast 1 blue and 1 red ball are drawing cans like (6,2) (5,3) (4,4)
(6,2)
⇒
7C6×5C2
⇒ 710 = 70
(5,3)
7C5×5C3
⇒ 21 x 10 = 210
(4,4)
⇒
7C4×5C4
⇒ 35 x 5 = 175
Sol:
11 + 1 = 2
22 – 2 = 2
32 + 3 = 12
4
42 – 4 = 12
52 + 5 = 30
62 – 6 = 30
So 7th term = (
82} – 8) = 56
Answer is 56
1, 4, 9, 18, 35 - - - - -
Sol:
21 – 1 = 1
2
2
22 + 0 = 4
23 + 1 = 9
24 + 2 = 18
25 + 3 = 35
So
26 + 4 = 68,
27 + 5 = 133,
28 +6 = 262
13. Rahul took a part in cycling game where 1/5 ahead of him and 5/6 behind him then total number of
participants =
Sol:
Let x be the total number of participants including Rahul.
Excluding rahul = (x – 1)
15(x–1)+56(x–1) = x
31x – 31 = 30x
What are the speeds two trains travels with 80 yards and 85 yards long respectively? (Assume that
former is faster than later)
x–y=
85
80
37.5
When moves in opposite direction the relative speed, x + y = 165/75 = 2.2 - - - - (II)
⇒ x = 1.165
15. Reversing the digits of father's age we get son's age. One year ago father was twice in age of that of
his son? find their current ages?
Sol:
At that point
(10x + y) – 1 = 2{(10y + x) – 1}
⇒ x = (19y – 1)/8
Let y = 3 then x = 7.
For any other y value, x value combined with y value doesn't give a realistic age (like father's age 120
etc)
1. X Z Y + X Y Z = Y Z X.
Sol:
⇒ Y=9
1st column, X + X + 1 = 9
⇒ X = 4 so, Z = 5
X = 4, Y = 9, Z = 5
2. In a 5 digit number, 3 pairs of sum is 11 each.last digit is 3 times first one,3rd digit is 3 less than 2nd,
4th digit is 4 more than the second one. Find the number.
Sol:
1st Digit
⇒a
2nd Digit
⇒b
3rd Digit
⇒ (b – 3)
4th digit
⇒ (b + 4)
5th Digit
⇒ 3a
Possible combinations -
1-3
2-6
3-9
5,4,3
3. GOOD is coded as 164 then BAD as 21. If UGLY coded as 260 then JUMP?
Sol:
G O O D = 7 + 15 + 15 + 4 = 41
41 x 4 = 164
Similarly
BAD=2+1+4=7
7x3
U G L Y = 21 + 7 + 12 + 25 = 65
65 x 4
Similarly,
J U M P = 10 + 21 + 13 + 16 = 60
60 x 4 = 240
4. Supposing a clock takes 7 seconds to strike 7. How long will it take to strike 10?
Sol:
Required time = (
Because time is only moving ahead ! so when we say between 1 to 2 hours, that means we assume only
1 hours not 2 hours.
5. An escalator is descending at constant speed. A walks down and takes 50 steps to reach the bottom. B
runs down and takes 90 steps in the same time as A takes 10 steps. How many steps are visible when
the escalator is not operating?
Sol:
Again it is given that B takes 90 steps to reach the bottom and time
taken by him for this is equal to time taken by A to cover 10 steps i.e
6. Albert and Fernandes have two leg swimming race. Both start from opposite ends of the pool. On the
first leg, the boys pass each other at 18 m from the deep end of the pool. During the second leg they
pass at 10 m from the shallow end of the pool. Both go at constant speed but one of them is faster. Each
boy rests for 4 seconds at the end of the first leg. What is the length of the pool?
Sol:
let their speed be x and y. So according to question the fast swimmer (let x) would start from shallow
end.
Thus
t1
18
x×t1=D–18 (1)
×
t
18
y×t1=18 (2)
18
18
Let t2 be the time after which they meet 2nd time (the 4 sec delay is cancelled as both wait for 4 sec)
So
D
–
10
(as x travelled one length complete to deep end + length from deep end to 10 m before shallow end)
10
(as y travelled one length complete to shallow end + 10 m from shallow end)
10
(
2
10
18
18
10
10
)
18(D–18)=(D+10)(2D–10)
solving we get
D x (D – 44) = 0
So D = 44 m answer.
Sol:
42,
62,
10
102,
18
182
which is of
2,4,8,?
2
21,
22,
23,
24
18
16
(18+16)2 = 1156
8. How many ways can one arrange the word EDUCATION such that relative positions of vowels and
consonants remains same?
Sol:
As the relative position of the vowels & consonants in any arrangement should remain the same as in
the word EDUCATION
The four vowels can be arranged in 3rd,5th,7th & 8th position in 4! ways.
similarly the five consonants can be arranged in 1st ,2nd ,4th, 6th & 9th position in 5! ways
120
24
2880
5!×4!=120×24=2880
9. There are 8 digits and 5 alphabets.In how many ways can you form an alphanumeric word using 3
digits and 2 alphabets?
Sol:
3
8C3 ways
5C2 ways
Now to form a alphanumeric word of 5 characters we have to arrange the 5 selected digits.
So the answer is .
8C3
5C2
× 5! = 43200
Sol:
n
C
nC2–n
For Octagon n = 8
Number of diagonals =
8C2 – 8 = 20
11. What is the next number of the following sequence 7, 14, 55, 110, _ ?
Sol:
7 + 7 =14
14 + 41 = 55
55 + 55 = 110
Sol:
4,8,12,16, - - - - - - - - , 96
Common difference,d = 4
Last number = l = 96
Number of terms = n
×d]
96 = 4 + (n –1)
×4
n = 24
13. 5 cars are to be parked in 5 parking slots. there are 3 red cars, 1 blue car and 1 green car. How many
ways the car can be parked?
Sol:
But according to question ,there are 3 red cars,so no. of ways for parking
3 red cars= 3!
so,
3
!
5!1!×3!×1! = 20 ways
14. 12 persons can complete the work in 18 days. after working for 6 days, 4 more persons added to
complete the work fast. in how many more days they will complete the work?
Sol:
Remaining days=
144
12
144(12+4)
Answer is 9 days
15. A set of football matches is to be organized in a "round-robin" fashion, i.e., every participating team
plays a match against every other team once and only once. If 21 matches are totally played, how many
teams participated?
Sol:
Consider number of teams be n
participating team plays a match against every other team once and only once.
Sequence folilows as
n(n+1)2
n(n–1)2
Equating formula to 21
n
n2 –
n – 42=0
Factors = 7,–6
Number of teams =7
Sol:
First term
3×12=3
Second term
32
4×23=32
Third term
405
5×34=405
Fourth term
6144
6×45=6144
17. A cube is divided into 729 identical cubelets. Each cut is made parallel to some surface of the cube .
But before doing that the cube is colored with green color on one set of adjacent faces ,red on the other
set of adjacent faces, blue on the third set. So, how many cubelets are there which are painted with
exactly one color?
Sol:
62
Sol:
Since hypotenuse is
62 cm.
Now, if we have an inscribed circle the property is the point where the circle touches the sides are
exactly 2/3 rd of the length of sides, i.e,
23×6 = 4 cm.
Now, if you drop 2 radii on the sides of triangle then they act as perpendiculars on sides. So, it forms a
small square of (6 – 4) = 2 cm each side.
19. How many boys are there in the class if the number of boys in the class is 8 more than the number of
girls in the class, which is five times the difference between the number of girls and boys in the class.
Sol:
Number of girls = g
then
given
b=5x8
b = 40
1. If dolly does not work hard then she can get A grade
3. If dolly does not gets an A grade then she must not have worked hard
Sol:
1. The hour hand lies between 3 and 4. Tthe difference between hour and minute hand is 50
degree.What are the two possible timings?
Sol:
The angle between the hour hand and minute hand at a given time H:MM is given by
θ = 30
×H –
2
11
211×MM
The time after H hours, hour hand and minute hand are at
MM = |
11
30
211×((30×H)±θ) |
given H = 3, MM = 50
θ=
80
11
8011,
280
11
28011
2. Jack and Jill went up and down a hill. They started from the bottom and Jack met Jill again 20 miles
from the top while returning. Jack completed the race 1 min a head of Jill. If the hill is 440 miles high and
their speed while down journey is 1.5 times the up journey. How long it took for the Jack to complete
the race ?
Sol:
Case 1 :
Jack met jill 20 miles from the top. So Jill travelled 440 – 20 = 420 miles.
Time taken for Jack to travel 440 miles up and 20 miles down = Time taken for Jill to travel 420 miles up
440
20
1.5
=
420
440x+201.5x=420y
68
1.5
420
681.5x=420y
68y = 63x
y=
63
68
63x68 ---(1)
Case 2 : Time taken for Jack to travel 440 miles up and 440 miles down = Time taken for Jill to travel 440
miles up and 440 miles down – 1
440
440
1.5
x
=
440
440
1.5
440x+4401.5x=440y+4401.5y – 1
440
440×53(1y−1x)=1-----(2)
x=4
40
63
40×5×53×63
t=
440
440×53(1x)
t = 12.6min
A, B, C, D have to stand in a queue in descending order of their heights. Who stands first?
D because A is not first neither C and B is not the tallest person. The only person will be first is D.
So option (C). We can answer this question using both the statements together.
4. One of the longest sides of the triangle is 20 m. The other side is 10 m. Area of the triangle is 80
Sol:
s
–
(s(s–a)×(s–b)×(s–c))
Where s =
(
30
(a+b+c)2=12×(30+c)
[Assume a = 20 ,b = 10]
Now,
a and b are two positive numbers. How many of them are odd?
II.
a2 – b is even.
Sol:
From the 1st statement b is even, as when multiplied by odd it gives even
a2 – b = even
⇒ a is even
Sol:
Weight of melon be m
x + 1 = 8 x m - - - - - - (1)
x + 2 x m = 1 - - - - - - (2)
Sol:
Observe that each letter appeared once, twice, thrice .... They form an arithmetic progression.
1+2+3......
n(n+1)2
So
(
n
n(n+1)2
≤ 288
For n = 23, we get 276. So for n = 24, the given series crosses 288.
Ans is X
8. If ABC =
C3 and CAB =
D3÷B3
Sol:
ABC =
C3
So, look for a number, that has a 3 digit cube, and the last digit of the cube is same as the number itself:
53 = 125
83
D = 8 and B = 2
83÷23
Answer = 64.
9. There are three trucks A, B, C. A loads 10 kg/min. B loads 13 1/3 kg/min. C unloads 5 kg/min. If three
simultaneously works then what is the time taken to load 2.4 tones?
Sol:
40
3
403 – 5=
55
553 kg/min
For 2.4 tonnes = 3/55 x 2.4 x 1000 = 130 mins = 2hrs 10min
10. If A =
x3y2 and B=
Sol:
A=
2
x3×y2
B=
x×y3
To find the HCF of the above numbers, take minimum power of x and y in both the numbers.
x×y2
Find value of R + H + O
Sol:
HERE
+ SHE
------------
COMES
------------
E + E = S = 8 => E = 4
3 digit no. + 4 digit no. = 5 digit no.
⇒ C = 1 ,O = 0, H = 9 etc
10348
– 894
--------
9454
-------
R + H + O = 5 + 9 + 0 = 14
12. A person is 80 years old in 490 and only 70 years old in 500 in which year is he born?
a) 400
b) 550
c) 570
d) 440
Sol:
13. Lucia is a wonderful grandmother and her age is between 50 and 70. Each of her sons have as many
sons as they have brothers. Their combined ages give Lucia's present age.what is the age?
Sol:
The question basically states that if Lucia were to have say 10 sons, then each son would have 9 sons
(Lucia's grandsons – since each son has 9 brothers). So the total in this case would be 9
×
Let us assume Lucia has got x sons. Now each son has (x - 1) sons. So total = x + (x - 1) x. For x = 8 we
get 64 which is in between 50 and 60. ( 7 x 8 grandsons + 8 sons = 64 )
14. A family X went for a vacation. Unfortunately it rained for 13 days when they were there. But
whenever it rained in the mornings, they had clear afternoons and vice versa. In all they enjoyed 11
mornings and 12 afternoons. How many days did they stay there totally?
Sol:
Sol:
2,3,5,7,11,...,43,47
Product =
7
×
11
43
47
2×3×5×7×11×−−−×43×47
There's a term
10
2×5=10
Sol:
HOW
+ MUCH
-------------
POWER
--------------
Here p = 1 and M = 9 because after adding carry bit it gives result 10. Hence O = 0,here three digits 0,1,9
have been used.
Now, put all remaining value in 3rd column and check which value is suitable for H,U and W and we get
H = 7,U = 8 and W = 5 and 1 carry which will be added in 4th column.
Now in first column we have W + H = R means 5 + 7 = 2 and 1 carry will add in 2nd column
Therefore,
9837
+ 705
---------
10542
---------
so P + O + W + E + R = 1 + 0 + 5 + 4 + 2 = 12
2 2 12 12 30 30 ?
Sol:
Answer is 56.
1x2=2
2x1=2
3 x 4 = 12
4 x 3 = 12
5 x 6 = 30
6 x 5 = 30
7 x 8 = 56
*************************************************************************************
What is C language?
Now that we have written a few programs let us look at the instructions that we used in these
programs. There are basically three types of instructions in C :
Type Declaration Instruction
Arithmetic Instruction
Control Instruction
4. What is a pointer?
Pointers are variables which stores the address of another variable. That variable may be a scalar
(including another pointer), or an aggregate (array or structure). The pointed-to object may be part of
a larger object, such as a field of a structure or an element in an array.
When using Call by Value, you are sending the value of a variable as parameter to a function, whereas
Call by Reference sends the address of the variable. Also, under Call by Value, the value in the parameter
is not affected by whatever operation that takes place, while in the case of Call by Reference, values can
be affected by the process within the function.
3) Some coders debug their programs by placing comment symbols on some codes instead of deleting it.
How does this aid in debugging?
Placing comment symbols /* */ around a code, also referred to as “commenting out”, is a way of
isolating some codes that you think maybe causing errors in the program, without deleting the code.
The idea is that if the code is in fact correct, you simply remove the comment symbols and continue on.
It also saves you time and effort on having to retype the codes if you have deleted it in the first place.
4) What is the equivalent code of the following statement in WHILE LOOP format?
Answer:
a=1;
while (a<=100) {
a++;
a=1;
while (a<=100) {
printf ("%d\n", a * a);
a++;
5) What is a stack?
A stack is one form of a data structure. Data is stored in stacks using the FILO (First In Last Out)
approach. At any particular instance, only the top of the stack is accessible, which means that in order to
retrieve data that is stored inside the stack, those on the upper part should be extracted first. Storing
data in a stack is also referred to as a PUSH, while data retrieval is referred to as a POP.
When writing programs that will store and retrieve data in a file, it is possible to designate that file into
different forms. A sequential access file is such that data are saved in sequential order: one data is
placed into the file after another. To access a particular data within the sequential access file, data has
to be read one data at a time, until the right one is reached.
This refers to the process wherein a variable is assigned an initial value before it is used in the program.
Without initialization, a variable would have an unknown value, which can lead to unpredictable outputs
when used in computations or other operations.
Spaghetti programming refers to codes that tend to get tangled and overlapped throughout the
program. This unstructured approach to coding is usually attributed to lack of experience on the part of
the programmer. Spaghetti programing makes a program complex and analyzing the codes difficult, and
so must be avoided as much as possible.
Source codes are codes that were written by the programmer. It is made up of the commands and other
English-like keywords that are supposed to instruct the computer what to do. However, computers
would not be able to understand source codes. Therefore, source codes are compiled using a compiler.
The resulting outputs are object codes, which are in a format that can be understood by the computer
processor. In C programming, source codes are saved with the file extension .C, while object codes are
saved with the file extension .OBJ
10) In C programming, how do you insert quote characters (‘ and “) into the output screen?
This is a common problem for beginners because quotes are normally part of a printf statement. To
insert the quote character as part of the output, use the format specifiers \’ (for single quote), and \”
(for double quote).
It is referred to as a terminating null character, and is used primarily to show the end of a string value.
The modulus operator outputs the remainder of a division. It makes use of the percentage (%) symbol.
For example: 10 % 3 = 1, meaning when you divide 10 by 3, the remainder is 1.
A nested loop is a loop that runs within another loop. Put it in another sense, you have an inner loop
that is inside an outer loop. In this scenario, the inner loop is performed a number of times as specified
by the outer loop. For each turn on the outer loop, the inner loop is first performed.
15) Which of the following operators is incorrect and why? ( >=, <=, <>, ==)
<> is incorrect. While this operator is correctly interpreted as “not equal to” in writing conditional
statements, it is not the proper operator to be used in C programming. Instead, the operator != must
be used to indicate “not equal to” condition.
Compilers and interpreters often deal with how program codes are executed. Interpreters execute
program codes one line at a time, while compilers take the program as a whole and convert it into
object code, before executing it. The key difference here is that in the case of interpreters, a program
may encounter syntax errors in the middle of execution, and will stop from there. On the other hand,
compilers check the syntax of the entire program and will only proceed to execution when no syntax
errors are found.
17) How do you declare a variable that will hold string values?
The char keyword can only hold 1 character value at a time. By creating an array of characters, you can
store string values in it. Example: “char MyName[50]; ” declares a string variable named MyName that
can hold a maximum of 50 characters.
18) Can the curly brackets { } be used to enclose a single line of code?
While curly brackets are mainly used to group several lines of codes, it will still work without error if you
used it for a single line. Some programmers prefer this method as a way of organizing codes to make it
look clearer, especially in conditional statements.
19) What are header files and what are its uses in C programming?
Header files are also known as library files. They contain two essential things: the definitions and
prototypes of functions being used in a program. Simply put, commands that you use in C programming
are actually functions that are defined from within each header files. Each header file contains a set of
functions. For example: stdio.h is a header file that contains definition and prototypes of commands like
printf and scanf.
Syntax errors are associated with mistakes in the use of a programming language. It maybe a command
that was misspelled or a command that must was entered in lowercase mode but was instead entered
with an upper case character. A misplaced symbol, or lack of symbol, somewhere within a line of code
can also lead to syntax error.
21) What are variables and it what way is it different from constants?
Variables and constants may at first look similar in a sense that both are identifiers made up of one
character or more characters (letters, numbers and a few allowable symbols). Both will also hold a
particular value. Values held by a variable can be altered throughout the program, and can be used in
most operations and computations. Constants are given values at one time only, placed at the beginning
of a program. This value is not altered in the program. For example, you can assigned a constant named
PI and give it a value 3.1415 . You can then use it as PI in the program, instead of having to write 3.1415
each time you need it.
Arrays contain a number of elements, depending on the size you gave it during variable declaration.
Each element is assigned a number from 0 to number of elements-1. To assign or retrieve the value of a
particular element, refer to the element number. For example: if you have a declaration that says
“intscores[5];”, then you have 5 accessible elements, namely: scores[0], scores[1], scores[2], scores[3]
and scores[4].
23) Can I use “int” data type to store the value 32768? Why?
No. “int” data type is capable of storing values from -32768 to 32767. To store 32768, you can use “long
int” instead. You can also use “unsigned int”, assuming you don’t intend to store negative values.
24) Can two or more operators such as \n and \t be combined in a single line of program code?
Yes, it’s perfectly valid to combine operators, especially if the need arises. For example: you can have a
code like ” printf (“Hello\n\n\’World\'”) ” to output the text “Hello” on the first line and “World”
enclosed in single quotes to appear on the next two lines.
25) Why is it that not all header files are declared in every C program?
The choice of declaring a header file at the top of each C program would depend on what
commands/functions you will be using in that program. Since each header file contains different
function definitions and prototype, you would be using only those header files that would contain the
functions you will need. Declaring all header files in every program would only increase the overall file
size and load of the program, and is not considered a good programming style.
When declaring functions, you will decide whether that function would be returning a value or not. If
that function will not return a value, such as when the purpose of a function is to display some outputs
on the screen, then “void” is to be placed at the leftmost part of the function header. When a return
value is expected after the function execution, the data type of the return value is placed instead of
“void”.
Compound statements are made up of two or more program statements that are executed together.
This usually occurs while handling conditions wherein a series of statements are executed when a TRUE
or FALSE is evaluated. Compound statements can also be executed within a loop. Curly brackets { } are
placed before and after compound statements.
Before a program can be written, an algorithm has to be created first. An algorithm provides a step by
step procedure on how a solution can be derived. It also acts as a blueprint on how a program will start
and end, including what process and computations are involved.
When storing multiple related data, it is a good idea to use arrays. This is because arrays are named
using only 1 word followed by an element number. For example: to store the 10 test results of 1
student, one can use 10 different variable names (grade1, grade2, grade3… grade10). With arrays, only 1
name is used, the rest are accessible through the index name (grade[0], grade[1], grade[2]… grade[9]).
JAVA QUESTION PAPER
JVM (Java Virtual Machine): It is an abstract machine. It is a specification that provides run-time
environment in which java bytecode can be executed. It follows three notations:
Specification: It is a document that describes the implementation of the Java virtual machine. It is
provided by Sun and other companies.
Runtime Instance: An instance of JVM is created whenever you write a java command on the command
prompt and run the class.
JRE (Java Runtime Environment) : JRE refers to a runtime environment in which java bytecode can be
executed. It implements the JVM (Java Virtual Machine) and provides all the class libraries and other
support files that JVM uses at runtime. So JRE is a software package that contains what is required to
run a Java program. Basically, it’s an implementation of the JVM which physically exists.
JDK(Java Development Kit) : It is the tool necessary to compile, document and package Java programs.
The JDK completely includes JRE which contains tools for Java programmers. The Java Development Kit
is provided free of charge. Along with JRE, it includes an interpreter/loader, a compiler (javac), an
archiver (jar), a documentation generator (javadoc) and other tools needed in Java development. In
short, it contains JRE + development tools.
Refer to this below image and understand how exactly these components reside:
public : Public is an access modifier, which is used to specify who can access this method. Public means
that this Method will be accessible by any Class.
static : It is a keyword in java which identifies it is class based i.e it can be accessed without creating the
instance of a Class.
void : It is the return type of the method. Void defines the method which will not return any value.
main: It is the name of the method which is searched by JVM as a starting point for an application with a
particular signature only. It is the method where the main execution occurs.
Platform independent practically means “write once run anywhere”. Java is called so because of its byte
codes which can run on any system irrespective of its underlying operating system.
Java is not 100% Object-oriented because it makes use of eight primitive datatypes such as boolean,
byte, char, int, float, double, long, short which are not objects.
Wrapper classes converts the java primitives into the reference types (objects). Every primitive data
type has a class dedicated to it. These are known as wrapper classes because they “wrap” the primitive
data type into an object of that class. Refer to the below image which displays different primitive type,
wrapper class and constructor argument.
In Java, constructor refers to a block of code which is used to initialize an object. It must have the same
name as that of the class. Also, it has no return type and it is automatically called when an object is
created.
There are two types of constructors:
Default constructor
Parameterized constructor
Q7. What is singleton class and how can we make a class singleton?
Singleton class is a class whose only one instance can be created at any given time, in one JVM. A class
can be made singleton by making its constructor private.
If an element is inserted into the Array List, it increases its Array size by 50%. Vector defaults to
doubling size of its array.
Array List does not define the increment size. Vector defines the increment size.
Array List can only use Iterator for traversing an Array List. Except Hashtable, Vector is the only
other class which uses both Enumeration and Iterator.
Equals() method is defined in Object class in Java and used for checking equality of two objects defined
by business logic.
“==” or equality operator in Java is a binary operator provided by Java programming language and used
to compare primitives and objects. public boolean equals(Object o) is the method provided by the
Object class. The default implementation uses == operator to compare two objects. For example:
method can be overridden like String class. equals() method is used to compare the values of two
objects.
if(Str1 == str2)
else
else
if(Str1.equals(str2))
else
}}
Q10. What are the differences between Heap and Stack Memory?
Memory Stack memory is used only by one thread of execution. Heap memory is used by all the
parts of the application.
Access Stack memory can’t be accessed by other threads. Objects stored in the heap are globally
accessible.
Memory Management Follows LIFO manner to free memory. Memory management is based on
generation associated to each object.
Lifetime Exists until the end of execution of the thread. Heap memory lives from the start till
the end of application execution.
Usage Stack memory only contains local primitive and reference variables to objects in heap space.
Whenever an object is created, it’s always stored in the Heap space.
In case you are facing any challenges with these java interview questions, please comment your
problems in the section below. Apart from this Java Interview Questions Blog, if you want to get trained
from professionals on this technology, you can opt for a structured training from edureka! Click below to
know more.
Compile time polymorphism is method overloading whereas Runtime time polymorphism is done using
inheritance and interface.
In Java, runtime polymorphism or dynamic method dispatch is a process in which a call to an overridden
method is resolved at runtime rather than at compile-time. In this process, an overridden method is
called through the reference variable of a superclass. Let’s take a look at the example below to
understand it better.
class Car {
void run()
System.out.println(“car is running”);
}
}
void run()
b.run();
An abstract class can provide complete, default code and/or just the details that have to be overridden.
An interface cannot provide any code at all,just the signature.
In case of abstract class, a class may extend only one abstract class. A Class may implement several
interfaces.
An abstract class can have non-abstract methods. All methods of an Interface are abstract.
An abstract class can have instance variables. An Interface cannot have instance variables
An abstract class can have any visibility: public, private, protected. An Interface visibility must be
public (or) none.
If we add a new method to an abstract class then we have the option of providing default
implementation and therefore all the existing code might work properly If we add a new method to an
Interface then we have to track down all the implementations of the interface and define
implementation for the new method
Method Overloading :
In Method Overloading, Methods of the same class shares the same name but each method must have
different number of parameters or parameters having different types and order.
class Adder {
return a+b;
return a+b;
System.out.println(Adder.add(11,11));
System.out.println(Adder.add(12.3,12.6));
}}
Method Overriding:
In Method Overriding, sub class have the same method with same name and exactly the same number
and type of parameters and same return type as a super class.
class Car {
void run(){
System.out.println(“car is running”);
void run()
b.run();
}
Q5. Can you override a private or static method in Java?
You cannot override a private or static method in Java. If you create a similar method with same return
type and same method arguments in child class then it will hide the super class method; this is known as
method hiding. Similarly, you cannot override a private method in sub class because it’s not accessible
there. What you can do is create another private method with the same name in the child class. Let’s
take a look at the example below to understand it better.
class Base {
obj1.display();
obj1.print();
MultipleInheritance - Java Interview Questions - EdurekaIf a child class inherits the property from
multiple classes is known as multiple inheritance. Java does not allow to extend multiple classes.
The problem with multiple inheritance is that if multiple parent classes have a same method name, then
at runtime it becomes difficult for the compiler to decide which method to execute from the child class.
Therefore, Java doesn’t support multiple inheritance. The problem is commonly referred as Diamond
Problem.
Association is a relationship where all object have their own lifecycle and there is no owner. Let’s take
an example of Teacher and Student. Multiple students can associate with a single teacher and a single
student can associate with multiple teachers but there is no ownership between the objects and both
have their own lifecycle. These relationship can be one to one, One to many, many to one and many to
many.
Aggregation is a specialized form of Association where all object have their own lifecycle but there is
ownership and child object can not belongs to another parent object. Let’s take an example of
Department and teacher. A single teacher can not belongs to multiple departments, but if we delete the
department teacher object will not destroy.
In case you are facing any challenges with these java interview questions, please comment your
problems in the section below. Apart from this Java Interview Questions Blog, if you want to get trained
from professionals on this technology, you can opt for a structured training from edureka! Click below to
know more.
*******************************
HR ROUND
How do you define success and how do you measure up to your own definition?