Oracle Financial Services Campus Recruitment - 2012
Aptitude Questions
BASIC COMPUTER KNOWLEDGE APTITUDE SECTION – Sample Questions
Java- Aptitude Questions
Basic level of the Java assessment. This is to test your skills in Fundamentals of java, Object Oriented P rogramming, Collections and Generics , etc...
Question Number 1
Which of the following correctly maps the default values of the array elements of the types indicated?
a. String → "null"
b. float → 0.0
c. boolean → true
d. char → '\u0000'
Question Number 3
Select from below options what is the right order in which the compilation units (class, interface, package and import statements) must appear in a file?
a. Package declaration
Import statements
Class, interface definitions
b. Import statements
Package declaration
Class, interface definitions
c. Package declaration
Class, interface definitions
Import statements
d. None of these
Question Number 4
Which of the following statements will NOT cause an early termination of the loop?
a. continue
b. return
c. System.exit()
d. break
Question Number 5
Consider the following lines of code:
1 byte xValue=64;
2 byte yValue=5;
3 byte zValue= (byte)(xValue*yValue);
After execution, what is the value of zValue?
a. 320
b. 0
c. 64
d. 645
Question Number 6
Select the static methods which are defined in the java.lang.String class.
a. valueOf
b. length
c. indexOf
d. compare
Question Number 7
Which of the following code fragments will compile without errors?
a. float f = 56.66;
b. boolean v = false,i;
c. double d = 34.56L;
d. char c = "d";
Question Number 8
Which of the following options correctly places a file named 'Test.java' in a directory 'src/test/'?
a. package src.test.Test.java;
b. package src;
package test;
public class Test
{
}
c. package src.test;
public class Test
{
}
d. package src/test;
public class Test
{
}
Question Number 9
Which of the following is the result of compiling and running the following program?
01 public class Test
02 {
03 public static final String TEST = "test";
04 public static void main(String[ ] args)
05 {
06 Test b = new Test();
07 Sub s = new Sub();
08 System.out.print(Test.TEST);
09 System.out.print(Sub.TEST) ;
10 System.out.print(b.TEST);
11 System.out.print(s.TEST);
12 System.out.print(((Test)s).TEST);
13 }
14 }
15 class Sub extends Test { public static final String TEST= "test1"; }
a. testtest1testtest1test
b. test1test1test1test1test1
c. testtesttesttest1test
d. testtesttesttest1test1
Question Number 10
With respect to the below code choose the correct option.
01 public class Test
02 {
03 private static String var1;
04 private int var2;
05 private String var3;
06 void method1()
07 {
08 String var4;
09 }
10 void method2()
11 {
12 }
13 void method3()
14 {
15 }
16 }
a. var4 is an instance variable
b. var2 is a class variable
c. var1 is a class variable
d. var3 is a local variable
Question Number 11
What will be the output of the following program?
01 class Parent
02 {
03 private final void callParent()
04 {
05 System.out.println("Parent");
06 }
07 }
08 public class Child extends Parent
09 {
10 public final void callParent()
11 {
12 System.out.println("Child");
13 }
14 public static void main(String [] args)
15 {
16 new Child ().callParent();
17 }
18 }
a. Child
b. Compilation fails
c. Child
d. Parent
Parent
Question Number 12
Consider a method with the below signature.
void test(Double r)
Which of the following invocations will result in a compiler error?
a. test(2)
b. test(.2d)
c. test(2D)
d. test(2.0)
Question Number 13
Which of the following statements is TRUE about the program given below?
01 interface Test1 { }
02 interface Test2 extends Test1 { }
03 class Test3 implements Test2 { }
04 class Test4 extends Test3 implements Test2 { }
05 public class Test
06 {
07 public static void main(String[] args)
08 {
09 System.out.println(new Test4() instanceof Test3); //line 1
10 System.out.println(new Test4() instanceof Test2);//line 2
11 System.out.println(new Test4() instanceof Test1);//line 3
12 System.out.println(new Test3() instanceof Test4);//line 4
13 System.out.println(new Test3() instanceof Test1);//line 5
14 }
15 }
a. All lines will evaluate to true
b. Only line 1 and 2 will evaluate to true
c. All lines will evaluate to true and only line 4 will evaluate to false
d. Lines 3 and 5 will evaluate to false
Question Number 14
Consider the following code segment:
1 import myLibrary.*;
2 class TestClass
3 {
4 // code for the class...
5 }
What should be the name of this file in order to compile and run the code segment successfully?
a. TestClass
b. TestClass.java
c. Any filename with the extension .java
d. TestClass.class
Question Number 15
Which of the following keywords cannot be used for an abstract method in abstract class?
a. abstract
b. static
c. public
d. void
Question Number 16
Consider a method with the below signature.
public void testDouble(double a)
Which of the following invocations will result in a compiler error?
a. testDouble(0.5+0.1)
b. testDouble(0.3,0.2)
c. testDouble(0.2f)
d. testDouble(0)
Question Number 17
A __________ is a collection with no duplicate elements.
a. List
b. Set
c. Map
d. Queue
Question Number 18
Which of the following is a Java collection interface?
a. ConcurrentSkipListSet
b. LinkedBlockingDeque
c. ConcurrentSkipListMap
d. NavigableMap
Question Number 19
Which of the following methods is to be used for adding elements to a generic Map?
a. insert()
b. put()
c. addvalue()
d. add()
Question Number 20
What is the legal syntax for accessing collection loop in generics?
a.
1 void printList(Collection<Object> c)
2 {
3 for (Object e =c)
4 {
5 System.out.println(e);
6 }
7 }
b.
1 void printList(Collection<Object> c)
2 {
3 for (int count=0 ; count < c.size();)
4 {
5 System.out.println(e);
6 }
7 }
c.
1 void printList(Collection<Object> c)
2 {
3 for (c)
4 {
5 System.out.println(e);
6 }
7 }
d.
view sourceprint?
1 void printList(Collection<Object> c)
2 {
3 for (Object e : c)
4 {
5 System.out.println(e);
6 }
7 }
Aptitude Questions
BASIC COMPUTER KNOWLEDGE APTITUDE SECTION – Sample Questions
Java- Aptitude Questions
Basic level of the Java assessment. This is to test your skills in Fundamentals of java, Object Oriented P rogramming, Collections and Generics , etc...
Question Number 1
Which of the following correctly maps the default values of the array elements of the types indicated?
a. String → "null"
b. float → 0.0
c. boolean → true
d. char → '\u0000'
Question Number 3
Select from below options what is the right order in which the compilation units (class, interface, package and import statements) must appear in a file?
a. Package declaration
Import statements
Class, interface definitions
b. Import statements
Package declaration
Class, interface definitions
c. Package declaration
Class, interface definitions
Import statements
d. None of these
Question Number 4
Which of the following statements will NOT cause an early termination of the loop?
a. continue
b. return
c. System.exit()
d. break
Question Number 5
Consider the following lines of code:
1 byte xValue=64;
2 byte yValue=5;
3 byte zValue= (byte)(xValue*yValue);
After execution, what is the value of zValue?
a. 320
b. 0
c. 64
d. 645
Question Number 6
Select the static methods which are defined in the java.lang.String class.
a. valueOf
b. length
c. indexOf
d. compare
Question Number 7
Which of the following code fragments will compile without errors?
a. float f = 56.66;
b. boolean v = false,i;
c. double d = 34.56L;
d. char c = "d";
Question Number 8
Which of the following options correctly places a file named 'Test.java' in a directory 'src/test/'?
a. package src.test.Test.java;
b. package src;
package test;
public class Test
{
}
c. package src.test;
public class Test
{
}
d. package src/test;
public class Test
{
}
Question Number 9
Which of the following is the result of compiling and running the following program?
01 public class Test
02 {
03 public static final String TEST = "test";
04 public static void main(String[ ] args)
05 {
06 Test b = new Test();
07 Sub s = new Sub();
08 System.out.print(Test.TEST);
09 System.out.print(Sub.TEST) ;
10 System.out.print(b.TEST);
11 System.out.print(s.TEST);
12 System.out.print(((Test)s).TEST);
13 }
14 }
15 class Sub extends Test { public static final String TEST= "test1"; }
a. testtest1testtest1test
b. test1test1test1test1test1
c. testtesttesttest1test
d. testtesttesttest1test1
Question Number 10
With respect to the below code choose the correct option.
01 public class Test
02 {
03 private static String var1;
04 private int var2;
05 private String var3;
06 void method1()
07 {
08 String var4;
09 }
10 void method2()
11 {
12 }
13 void method3()
14 {
15 }
16 }
a. var4 is an instance variable
b. var2 is a class variable
c. var1 is a class variable
d. var3 is a local variable
Question Number 11
What will be the output of the following program?
01 class Parent
02 {
03 private final void callParent()
04 {
05 System.out.println("Parent");
06 }
07 }
08 public class Child extends Parent
09 {
10 public final void callParent()
11 {
12 System.out.println("Child");
13 }
14 public static void main(String [] args)
15 {
16 new Child ().callParent();
17 }
18 }
a. Child
b. Compilation fails
c. Child
d. Parent
Parent
Question Number 12
Consider a method with the below signature.
void test(Double r)
Which of the following invocations will result in a compiler error?
a. test(2)
b. test(.2d)
c. test(2D)
d. test(2.0)
Question Number 13
Which of the following statements is TRUE about the program given below?
01 interface Test1 { }
02 interface Test2 extends Test1 { }
03 class Test3 implements Test2 { }
04 class Test4 extends Test3 implements Test2 { }
05 public class Test
06 {
07 public static void main(String[] args)
08 {
09 System.out.println(new Test4() instanceof Test3); //line 1
10 System.out.println(new Test4() instanceof Test2);//line 2
11 System.out.println(new Test4() instanceof Test1);//line 3
12 System.out.println(new Test3() instanceof Test4);//line 4
13 System.out.println(new Test3() instanceof Test1);//line 5
14 }
15 }
a. All lines will evaluate to true
b. Only line 1 and 2 will evaluate to true
c. All lines will evaluate to true and only line 4 will evaluate to false
d. Lines 3 and 5 will evaluate to false
Question Number 14
Consider the following code segment:
1 import myLibrary.*;
2 class TestClass
3 {
4 // code for the class...
5 }
What should be the name of this file in order to compile and run the code segment successfully?
a. TestClass
b. TestClass.java
c. Any filename with the extension .java
d. TestClass.class
Question Number 15
Which of the following keywords cannot be used for an abstract method in abstract class?
a. abstract
b. static
c. public
d. void
Question Number 16
Consider a method with the below signature.
public void testDouble(double a)
Which of the following invocations will result in a compiler error?
a. testDouble(0.5+0.1)
b. testDouble(0.3,0.2)
c. testDouble(0.2f)
d. testDouble(0)
Question Number 17
A __________ is a collection with no duplicate elements.
a. List
b. Set
c. Map
d. Queue
Question Number 18
Which of the following is a Java collection interface?
a. ConcurrentSkipListSet
b. LinkedBlockingDeque
c. ConcurrentSkipListMap
d. NavigableMap
Question Number 19
Which of the following methods is to be used for adding elements to a generic Map?
a. insert()
b. put()
c. addvalue()
d. add()
Question Number 20
What is the legal syntax for accessing collection loop in generics?
a.
1 void printList(Collection<Object> c)
2 {
3 for (Object e =c)
4 {
5 System.out.println(e);
6 }
7 }
b.
1 void printList(Collection<Object> c)
2 {
3 for (int count=0 ; count < c.size();)
4 {
5 System.out.println(e);
6 }
7 }
c.
1 void printList(Collection<Object> c)
2 {
3 for (c)
4 {
5 System.out.println(e);
6 }
7 }
d.
view sourceprint?
1 void printList(Collection<Object> c)
2 {
3 for (Object e : c)
4 {
5 System.out.println(e);
6 }
7 }
No comments:
Post a Comment