British Telecom Written Test
Aptitude - 25 Question in 25 mins
20 questions were data interpretation, example question below-
The one was from CAT 2007
Solution
20 questions were data interpretation, example question below-
The one was from CAT 2007
Solution
Java - 35 Questions in 35 mins
10 of them being multiple answer type with 5 options. Below are a few sample questions I can remember.
Q1 Select all the methods of Thread class that are static.
1. yield()
2. sleep()
3. wait()
4. run()
5. join()
Q2 Select all the valid declaration for interface.
1.
interface Test {
public int a = 100;
public void test() throws RuntimeException;
}
2.
abstract interface Test {
public int a = 100;
public void test() throws RuntimeException;
}
3. interface Test {
public int a = 100;
public void test();
}
Some more options i don't recall. All the above are valid declaration.
Q3 Conside the following declaration.
class Tyre { public void front() throws RuntimeException { System.out.println("Tire"); } public void front(long a) { System.out.println("Radial Tire with long"); } } class RadialTyre extends Tyre { public void front() { System.out.println("Radial Tire"); } public void front(int a) throws RuntimeException { System.out.println("Radial Tire with int"); } } public static void main(String... args) { Tyre t = new RadialTyre(); int a = 10; t.front(a); }Select the correct output.
1. Radial Tyre Radial Tire with long
2. Radial Tyre Radial Tire with int
3. Tire Radial Tire with long
4. Tire Radial Tire with int
Q4 Using the declaration of question 3, consider the following the select the correct option.
public static void main(String... args) { System.out.println("This is just a test"); Tyre t = new RadialTyre(); Tyre t1 = new Tyre(); RadialTyre r = new RadialTyre(); System.out.println(Tyre instanceof t1); //Line 1 System.out.println(t1 instanceof RadialTyre); //Line 2 System.out.println(Tyre instanceof r); //Line 3 System.out.println(r instanceof RadialTyre); //Line 4 }1. True False True True
2. False False True True
3. True True True True
4. Compile Time error at line 1 and 3
5. Compile Timer error at line 2 and 4
Q5 Consider the following program
public static void main(String... args) { SetSelect the correct output-nodeSet = new HashSet System.out.println(nodeSet.size()); }(); nodeSet.add(new Node(10)); nodeSet.add(new Node(20)); nodeSet.add(new Node(30)); nodeSet.add(new Node(10)); nodeSet.add(new Node(20));
1. 5 2. 3 3. Compile Time Error 4. RunTimeException
Q6 Consider the following program
public static void main(String... args) { List list = new ArrayList(); list.add(new Node(10)); list.add(new String("Harsh")); System.out.println(list.get(1)); }Select the correct output-1. 10 2. Harsh 3. CompileTimeError 4. CastClassException
Note: Correct answer is in bold
Comment below if you find this useful. This is just for reference and making up you mind.
thanks for the questions
ReplyDeleteHi Anshul have u attended the test please let me know the type of question .
ReplyDeleteAnswer to question no.4 is wrong
ReplyDeleteIt should be option 4. Compile Time error at line 1 and 3
thanks, corrected..!!
Deleteanswer to que5 is wrong , FOr Hashset the ans will be 3 , it will take duplicate values.
ReplyDeletesorry , it will not take duplicate values .
DeleteIf you look closely..
Deletetheir is NO duplication happening while creating object of class "Node" using new keyword. Every time a separate object is getting created. Therefore answer:5
This comment has been removed by the author.
DeleteAnswer to the fifth question is option 2.
ReplyDeleteoption 1 is the correct answer, it will be option 2 if you override hashcode and equals
DeleteWhy think, when you can try. I tried, the answer came to option 2, as Oracle has ensured that you do not fool the add method into increasing size, even if you are adding duplicate values
DeleteI think u tried by using Integer or String instead of node. Answer came 5 when i used a nested node class .
DeleteHere is the code
:-
package exp;
import java.util.HashSet;
import java.util.Set;
public class Main {
private static class node{
private int i ;
public node(int i ){
this.i = i ;
}
}
public static void main(String[] args) {
Set nodeSet = new HashSet();
nodeSet.add(new node(10));
nodeSet.add(new node(20));
nodeSet.add(new node(30));
nodeSet.add(new node(10));
nodeSet.add(new node(20)); //
System.out.println(nodeSet.size());
}
}
,,
ReplyDeletecould you post more questions if possible
ReplyDeleteVery help ful. these snippets are.Thanks man.
ReplyDeleteCan someone pls explain the third ques in brief
ReplyDeleteThis comment has been removed by the author.
DeleteIn overloading, method resolution takes care by compiler based on reference type.
DeleteSince it's a overloading method call, the Tyre class(Parent class) method will be called here.
P.S. In Overriding, method resolution takes care by JVM based on runtime object which is nothing but Radial Tyre(child class).
but in our example it's overloading not the overriding.
Thanks Abhijit
Deletehelpful thanx bro
ReplyDeleteCan you please post more aptitude questions, if you remember.
DeleteThanks for the questions helped me a lot...
ReplyDeletevery helpfull.. thanks
ReplyDeleteCan you please post more aptitude questions, if you remember.
Delete