1

MakeMyTrip bangalore selection process [mettl.com]

For interviews to be conducted on 1-4 march 2014 MakeMyTrip conducting online screening test

Test by mettl.com for makemytrip.com

Coding Section (1 Question) :

For the given number N (0 < N <= 2000). little Johnny wants to find out a minimum positive Integer X divisible  by N. where the sum of digits of X is equal to N and X is not equal to N
For example:
N          :Result
1          :1
10        190

ans:
public static int findNum(int n) {
            int  tnum = n ;
                            while (tnum <= 1000){
                               int tempnum = tnum;
                              int  sum = 0;
                                while (tempnum > 0){
                                    sum = sum + (tempnum % 10);
                                    tempnum = (int) (tempnum / 10);
                                if (sum == n)
                                    return tnum;
                                }
                                tnum = tnum + n;
                            }
                            return  tnum;

      }


MCQ (15 Question)

1. . which is the correct output option
public class Test {
     
static int[] i ;
      static {i[0]=11;}

      public static void main(String[] args) {
       
               String str1= "Manish";
String str2="ManishKumar";

System.out.println(str1.compareTo(str2));    

}
1.       ExceptionInInitializerError
2.       Some option
3.       Some option
4.       Some option

2. which is the correct output option
public class Test {
     
      public static void main(String[] args) {
       
               String str1= Manish;
String str2=ManishKumar;

System.out.println(str1.compareTo(str2));
}
1.       -5
2.       1
3.       Compile error
4.       Some option

3. what is the best difference between Runtime.exit() and Runtime.halt()

  1. 1.       System.exit() will be internally converted into RunTime.getRuntime().exit()
  2. 2.       Runtime.exit() causes uninvoked finalizers to be executed before the JVM process shuts down but Runtime.halt() doesn't
  3. 3.       Some option saying jvm to shutdown
  4. 4.       Some option

4.  which is the correct output option
public class Test {
     
      public static void main(String[] args) {
       
                  int x=10;
                  int y=++(++x);
                  System.out.println(y);
    

}
5. which is the correct output option
public class Test {
     
      public static void main(String[] args) {
     
Set s = new HashSet();
            s.add("akash");
            s.add("anshu");
            s.add("akash");
            Iterator it =     s.iterator();
            while (it.hasNext()) {
                   System.out.println( it.next());
                 
            }    
    

}

6. which is the correct output option
public class Test {
     
      public static void main(String[] args) {
                         
Set s = new HashSet();
            s.add(null);
            s.add(5);
            Iterator it =     s.iterator();
            while (it.hasNext()) {
                   System.out.println( it.next());
                 
            }
}

7.  which is the correct output option
class Dog {
      public Dog(int i) {
            // TODO Auto-generated constructor stub
      }
}
public class Test {
     
      public static void main(String[] args) {
                       
            TreeSet<Dog> d= new TreeSet<Dog>();
            d.add(new Dog(1));
            d.add(new Dog(2));
            d.add(new Dog(3));
           
            System.out.println(d.size());
}

8. which is the correct output  option
try {
                  System.out.println("Division");
                  int x=10/0;
                  System.out.println(x);
            } catch (Exception e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }
1.       Division  by Zero ArithMaticException
2.       by Zero ArithMaticException
3.       ArithMaticException
4.       Some option

9. what is the correct output option
List l = new ArrayList();
             l.add("abc");
             l.add("8");
             l.add("5");
             Collections.sort(l);
             
             for (int i = 0; i < l.size(); i++) {
                  System.out.println(l.get(i));            
            }

10.  which of the following is the correct option
public class Test{
     
     
      void check() throws Exception {
            System.out.println("check");
      }   
      public static void main(String[]args) {
           
            Test dt = new Test();
            dt.check();
      }
}
  1. 1.  compile
  2. 2.  RuntimeException
  3. 3.  Someoption
  4. 4.  No of the above


11. which is not correct option
a.       public static void main(String ...args)
b.      public static void main(String[] args) throws Exception
c.       public static void main(String  args)
d.      public static void main(String[]  args)

12.   which of the following is the correct option <same as q10>
public class Test{
     
     
      void check() throws RuntimeException {
            System.out.println("check");
      }   
      public static void main(String[]args) {
           
            Test dt = new Test();
            dt.check();
      }
}
  • 1.  compile
  • .  RuntimeException
  • .  Someoption
  •   No of the above



13. Find the override and over load  relationship         
Public class Child {
      void display (){}//Line 1
}          
  class Child extends Parent {
 display (){} // Line a
             void display(int i){ //Line b
}  
 }                                                          
a.       Line 1 and Line a are overridden ; Line a and Line b are overloaded
b.       Similar  other Option
c.       Similar   other  Option
d.      Similar  other  Option

14.                How to start a thread having a class test impliments Runnable and overrides Run method
                                a .     Test dt = new Test();
                  Thread th = new Thread(dt);
                  th.start();
                                b.     Thread th = new Thread(Test);
c.
d.   

                   
15.          Object o = new Object();
            //Line 2
            s.add("o");
            s.add(o);
            which one will not compile at Line 2 ?
a.  Set s = new HashSet();
b.  Set s = new LinkedHashSet();
c.   Set s = new TreeSet();
d.  No Compile issue



Interview Questions :


  1. Given 25 horses , find 3 fastest horses on condition  max 5 horses/race can run ? no stopwatch provided 
  2. Given two linked-list find common element , please note don't find common value but address ie  nodes in two list  pointing to same address
  3. if you have an array{a,b,c}   replace each value in array with the product of other elements ie{bc,ac,ab} . code  should work for given n array elements 

All the best ! 

1 comment:

  1. a small bug in first code .

    if (sum == n) {
    return tnum;
    }

    should be out of second loop

    ReplyDelete