Explore topic-wise MCQs in Accenture.

This section includes 30 Mcqs, each offering curated multiple-choice questions to sharpen your Accenture knowledge and support exam preparation. Choose a topic below to get started.

1.

Assume the following method is properly synchronized and called from a thread A on an object B: wait(2000); After calling this method, when will the thread A become a candidate to get another turn at the CPU?

A. After thread A is notified, or after two seconds.
B. After the lock on B is released, or after two seconds.
C. Two seconds after thread A is notified.
D. Two seconds after lock B is released.
Answer» B. After the lock on B is released, or after two seconds.
2.

Which will contain the body of the thread?

A. run();
B. start();
C. stop();
D. main();
Answer» B. start();
3.

Which method must be defined by a class implementing the java.lang.Runnable interface?

A. void run()
B. public void run()
C. public void start()
D. void run(int priority)
Answer» C. public void start()
4.

Which of the following will directly stop the execution of a Thread?

A. wait()
B. notify()
C. notifyall()
D. exits synchronized code
Answer» B. notify()
5.

Which cannot directly cause a thread to stop executing?

A. Calling the SetPriority() method on a Thread object.
B. Calling the wait() method on an object.
C. Calling notify() method on an object.
D. Calling read() method on an InputStream object.
Answer» D. Calling read() method on an InputStream object.
6.

What is the name of the method used to start a thread execution?

A. init();
B. start();
C. run();
D. resume();
Answer» C. run();
7.

What is the numerical range of char?

A. 0 to 32767
B. 0 to 65535
C. -256 to 255
D. -32768 to 32767
Answer» C. -256 to 255
8.

Which is valid declaration of a float?

A. float f = 1F;
B. float f = 1.0;
C. float f = "1";
D. float f = 1.0d;
Answer» B. float f = 1.0;
9.

Which collection class allows you to access its elements by associating a key with an element's value, and provides synchronization?

A. java.util.SortedMap
B. java.util.TreeMap
C. java.util.TreeSet
D. java.util.Hashtable
Answer» E.
10.

Which collection class allows you to associate its elements with key values, and allows you to retrieve objects in FIFO (first-in, first-out) sequence?

A. java.util.ArrayList
B. java.util.LinkedHashMap
C. java.util.HashMap
D. java.util.TreeMap
Answer» C. java.util.HashMap
11.

Which interface provides the capability to store objects using a key-value pair?

A. Java.util.Map
B. Java.util.Set
C. Java.util.List
D. Java.util.Collection
Answer» B. Java.util.Set
12.

Which interface does java.util.Hashtable implement?

A. Java.util.Map
B. Java.util.List
C. Java.util.HashTable
D. Java.util.Collection
Answer» B. Java.util.List
13.

You need to store elements in a collection that guarantees that no duplicates are stored and all elements can be accessed in natural order. Which interface provides that capability?

A. java.util.Map
B. java.util.Set
C. java.util.List
D. java.util.Collection
Answer» C. java.util.List
14.

Which collection class allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized?

A. java.util.HashSet
B. java.util.LinkedHashSet
C. java.util.List
D. java.util.ArrayList
Answer» E.
15.

Which class does not override the equals() and hashCode() methods, inheriting them directly from class Object?

A. java.lang.String
B. java.lang.Double
C. java.lang.StringBuffer
D. java.lang.Character
Answer» D. java.lang.Character
16.

Suppose that you would like to create an instance of a new Map that has an iteration order that is the same as the iteration order of an existing instance of a Map. Which concrete implementation of the Map interface should be used for the new instance?

A. TreeMap
B. HashMap
C. LinkedHashMap
D. The answer depends on the implementation of the existing instance.
Answer» D. The answer depends on the implementation of the existing instance.
17.

public class Test { } What is the prototype of the default constructor?

A. Test( )
B. Test(void)
C. public Test( )
D. public Test(void)
Answer» D. public Test(void)
18.

You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access that accomplishes this objective?

A. public
B. private
C. protected
D. transient
Answer» D. transient
19.

Which is a valid declaration within an interface?

A. public static short stop = 23;
B. protected short stop = 23;
C. transient short stop = 23;
D. final void madness(short stop);
Answer» B. protected short stop = 23;
20.

Given a method in a protected class, what access modifier do you use to restrict access to that method to only the other members of the same class?

A. final
B. static
C. private
D. protected
E. volatile
Answer» D. protected
21.

Which of the following class level (nonlocal) variable declarations will not compile?

A. protected int a;
B. transient int b = 3;
C. private synchronized int e;
D. volatile int d;
Answer» D. volatile int d;
22.

Which one creates an instance of an array?

A. int[ ] ia = new int[15];
B. float fa = new float[20];
C. char[ ] ca = "Some String";
D. int ia[ ] [ ] = { 4, 5, 6 }, { 1,2,3 };
Answer» B. float fa = new float[20];
23.

You want a class to have access to members of another class in the same package. Which is the most restrictive access that accomplishes this objective?

A. public
B. private
C. protected
D. default access
Answer» E.
24.

Which cause a compiler error?

A. int[ ] scores = {3, 5, 7};
B. int [ ][ ] scores = {2,7,6}, {9,3,45};
C. String cats[ ] = {"Fluffy", "Spot", "Zeus"};
D. boolean results[ ] = new boolean [] {true, false, true};
E. Integer results[ ] = {new Integer(3), new Integer(5), new Integer(8)};
Answer» C. String cats[ ] = {"Fluffy", "Spot", "Zeus"};
25.

What is the most restrictive access modifier that will allow members of one class to have access to members of another class in the same package?

A. public
B. abstract
C. protected
D. synchronized
E. default access
Answer» F.
26.

What is the value of "d" after this line of code has been executed? double d = Math.round ( 2.5 + Math.random() );

A. 2
B. 3
C. 4
D. 2.5
Answer» C. 4
27.

Which of the following would compile without error?

A. int a = Math.abs(-5);
B. int b = Math.abs(5.0);
C. int c = Math.abs(5.5F);
D. int d = Math.abs(5L);
Answer» B. int b = Math.abs(5.0);
28.

Which constructs an anonymous inner class instance?

A. Runnable r = new Runnable() { };
B. Runnable r = new Runnable(public void run() { });
C. Runnable r = new Runnable { public void run(){}};
D. System.out.println(new Runnable() {public void run() { }});
Answer» E.
29.

Which statement is true about a static nested class?

A. You must have a reference to an instance of the enclosing class in order to instantiate it.
B. It does not have access to nonstatic members of the enclosing class.
C. Its variables and methods must be static.
D. It must extend the enclosing class.
Answer» C. Its variables and methods must be static.
30.

Which is true about a method-local inner class?

A. It must be marked final.
B. It can be marked abstract.
C. It can be marked public.
D. It can be marked static.
Answer» C. It can be marked public.