0% found this document useful (0 votes)
19 views1 page

Interview Test Questions

The document describes an algorithm to check if a string containing brackets is valid or not. It also asks to design code for a Maruti and BMW class in object oriented programming, where the Maruti and BMW classes have a currentSpeed attribute and an increaseSpeed method that changes the speed differently depending on a boost parameter.

Uploaded by

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

Interview Test Questions

The document describes an algorithm to check if a string containing brackets is valid or not. It also asks to design code for a Maruti and BMW class in object oriented programming, where the Maruti and BMW classes have a currentSpeed attribute and an increaseSpeed method that changes the speed differently depending on a boost parameter.

Uploaded by

Sushil Nachnani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

3. You have a string “()(((())()))” or a similar string with round brackets.

Can
you create algorithm for checking if
string is valid. For example:
()() is valid
(()(()())) is valid
()()) is not valid
())(() is not valid
())))(((
This is similar to a compiler checking for valid syntax in "if" statements. All
brackets have to be closed
correctly or the compiler will throw an error.
Fully working code is not necessary, algorithm is enough.
Also describe your algorithm, why you have chosen to solve it that way.What are
other options? Which
is faster to create, and which works faster?
4. Object oriented programming: Design and write the code for the following. Use
any language that you know:
There is a Maruti class. It has an attribute called currentSpeed. It has a method
called increaseSpeed.
This method has a parameter boost. if boost is equal to "bad" then speed should
decrease by 5. if boost
is equal to "fair" then speed should increase by 5. if boost is equal to "good"
then speed should increase
by10. if boost is equal to "turbo" then speed should increase by 20. If the car
hits a speed of one of
100/125/150 a message should be printed - "Congratulations! you have reached a
speed of X"
There is a BMW class. In BMW for the same boost values - speed should increase at a
faster rate e.g. if
boost equal to "fair" speed should increase by 10, if boost equal to "good" speed
should increase by 15
and so on. Design and code this using OOPs concepts so that the BMW class has
minimum code - don't
have the entire code from Maruti class in the BMW class. (hint: use an additional
variable)

You might also like