The Following Section consists of Computer MCQ on Java Programming. Select the correct option to test your Computer skills on Java Programming.
Quiz-summary
0 of 20 questions completed
Questions:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
Information
Computer Questions on Java Programming
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You have to finish following quiz, to start this quiz:
Results
0 of 20 questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 points, (0)
| Average score |
|
| Your score |
|
Categories
- Computer 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- Answered
- Review
-
Question 1 of 20
1. Question
1 pointsWhich four options describe the correct default values for array elements of the types indicated?
int -> 0 String -> “null” Dog -> null char -> ‘\u0000’ float -> 0.0f boolean -> true
Correct
Incorrect
-
Question 2 of 20
2. Question
1 pointsWhich one of these lists contains only Java programming language keywords?
Correct
Incorrect
-
Question 3 of 20
3. Question
1 pointsWhich will legally declare, construct, and initialize an array?
Correct
Incorrect
-
Question 4 of 20
4. Question
1 pointsWhich is a reserved word in the Java programming language?
Correct
Incorrect
-
Question 5 of 20
5. Question
1 pointsWhich is a valid keyword in java?
Correct
Incorrect
-
Question 6 of 20
6. Question
1 pointsWhich three are legal array declarations?
int [] myScores []; char [] myChars; int [6] myScores; Dog myDogs []; Dog myDogs [7];
Correct
Incorrect
-
Question 7 of 20
7. Question
1 pointsWhich one of the following will declare an array and initialize it with five numbers?
Correct
Incorrect
-
Question 8 of 20
8. Question
1 pointsWhich three are valid declarations of a char?
char c1 = 064770; char c2 = ‘face’; char c3 = 0xbeef; char c4 = \u0022; char c5 = ‘\iface’; char c6 = ‘\uface’;
Correct
Incorrect
-
Question 9 of 20
9. Question
1 pointsWhich is the valid declarations within an interface definition?
Correct
Incorrect
-
Question 10 of 20
10. Question
1 pointsWhich one is a valid declaration of a boolean?
Correct
Incorrect
-
Question 11 of 20
11. Question
1 pointsWhich three are valid declarations of a float?
float f1 = -343; float f2 = 3.14; float f3 = 0x12345; float f4 = 42e7; float f5 = 2001.0D; float f6 = 2.81F;
Correct
Incorrect
-
Question 12 of 20
12. Question
1 pointsWhich is a valid declarations of a String?
Correct
Incorrect
-
Question 13 of 20
13. Question
1 pointsWhat is the numerical range of a char?
Correct
Incorrect
-
Question 14 of 20
14. Question
1 pointsYou want subclasses in any package to have access to members of a superclass. Which is the most restrictive access that accomplishes this objective?
Correct
Incorrect
-
Question 15 of 20
15. Question
1 pointsWhich three form part of correct array declarations?
public int a [ ] static int [ ] a public [ ] int a private int a [3] private int [3] a [ ] public final int [ ] a
Correct
Incorrect
-
Question 16 of 20
16. Question
1 pointspublic class Test { } What is the prototype of the default constructor?
Correct
Incorrect
-
Question 17 of 20
17. Question
1 pointsWhat 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?
Correct
Incorrect
-
Question 18 of 20
18. Question
1 pointsWhich of the following is/are legal method declarations?
protected abstract void m1(); static final void m1(){} synchronized public final void m1() {} private native void m1();
Correct
Incorrect
-
Question 19 of 20
19. Question
1 pointsWhich cause a compiler error?
Correct
Incorrect
-
Question 20 of 20
20. Question
1 pointsWhich three are valid method signatures in an interface?
private int getArea(); public float getVol(float x); public void main(String [] args); public static void main(String [] args); boolean setFlag(Boolean [] test);
Correct
Incorrect
Quiz-summary
0 of 20 questions completed
Questions:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
Information
Computer Questions on Java Programming 2
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You have to finish following quiz, to start this quiz:
Results
0 of 20 questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 points, (0)
| Average score |
|
| Your score |
|
Categories
- Computer 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- Answered
- Review
-
Question 1 of 20
1. Question
1 pointsYou 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?
Correct
Incorrect
-
Question 2 of 20
2. Question
1 pointsWhich one creates an instance of an array?
Correct
Incorrect
-
Question 3 of 20
3. Question
1 pointsWhich two of the following are legal declarations for nonnested classes and interfaces?
final abstract class Test {} public static interface Test {} final public class Test {} protected abstract class Test {} protected interface Test {} abstract public class Test {}
Correct
Incorrect
-
Question 4 of 20
4. Question
1 pointsWhich of the following class level (nonlocal) variable declarations will not compile?
Correct
Incorrect
-
Question 5 of 20
5. Question
1 pointsWhich two cause a compiler error?
float[ ] f = new float(3); float f2[ ] = new float[ ]; float[ ]f1 = new float[3]; float f3[ ] = new float[3]; float f5[ ] = {1.0f, 2.0f, 2.0f};
Correct
Incorrect
-
Question 6 of 20
6. Question
1 pointsGiven 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?
Correct
Incorrect
-
Question 7 of 20
7. Question
1 pointsWhich is a valid declaration within an interface?
Correct
Incorrect
-
Question 8 of 20
8. Question
1 pointsWhich is true about an anonymous inner class?
Correct
Incorrect
-
Question 9 of 20
9. Question
1 pointsWhich is true about a method-local inner class?
Correct
Incorrect
-
Question 10 of 20
10. Question
1 pointsWhich statement is true about a static nested class?
Correct
Incorrect
-
Question 11 of 20
11. Question
1 pointsWhich constructs an anonymous inner class instance?
Correct
Incorrect
-
Question 12 of 20
12. Question
1 pointsWhat is the value of “d” after this line of code has been executed?
double d = Math.round ( 2.5 + Math.random() );
Correct
Incorrect
-
Question 13 of 20
13. Question
1 pointsWhich of the following would compile without error?
Correct
Incorrect
-
Question 14 of 20
14. Question
1 pointsWhich of the following are valid calls to Math.max?
Math.max(1,4) Math.max(2.3, 5) Math.max(1, 3, 5, 7) Math.max(-1.5, -2.8f)
Correct
Incorrect
-
Question 15 of 20
15. Question
1 pointsWhat is the name of the method used to start a thread execution?
Correct
Incorrect
-
Question 16 of 20
16. Question
1 pointsWhich two are valid constructors for Thread?
Thread(Runnable r, String name) Thread() Thread(int priority) Thread(Runnable r, ThreadGroup g) Thread(Runnable r, int priority)
Correct
Incorrect
-
Question 17 of 20
17. Question
1 pointsWhich three are methods of the Object class?
notify(); notifyAll(); isInterrupted(); synchronized(); interrupt(); wait(long msecs); sleep(long msecs); yield();
Correct
Incorrect
-
Question 18 of 20
18. Question
1 pointsWhich cannot directly cause a thread to stop executing?
Correct
Incorrect
-
Question 19 of 20
19. Question
1 pointsWhich two of the following methods are defined in class Thread?
start() wait() notify() run() terminate()
Correct
Incorrect
-
Question 20 of 20
20. Question
1 pointsWhich three guarantee that a thread will leave the running state?
yield() wait() notify() notifyAll() sleep(1000) aLiveThread.join() Thread.killThread()
Correct
Incorrect
Quiz-summary
0 of 20 questions completed
Questions:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
Information
Computer Questions on Java Programming 3
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You have to finish following quiz, to start this quiz:
Results
0 of 20 questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 points, (0)
| Average score |
|
| Your score |
|
Categories
- Computer 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- Answered
- Review
-
Question 1 of 20
1. Question
1 pointsWhich of the following will directly stop the execution of a Thread?
Correct
Incorrect
-
Question 2 of 20
2. Question
1 pointsWhich method must be defined by a class implementing the java.lang.Runnable interface?
Correct
Incorrect
-
Question 3 of 20
3. Question
1 pointsWhich will contain the body of the thread?
Correct
Incorrect
-
Question 4 of 20
4. Question
1 pointsWhich method registers a thread in a thread scheduler?
Correct
Incorrect
-
Question 5 of 20
5. Question
1 pointsAssume 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?
Correct
Incorrect
-
Question 6 of 20
6. Question
1 pointsWhich of the following will not directly cause a thread to stop?
Correct
Incorrect
-
Question 7 of 20
7. Question
1 pointsWhich class or interface defines the wait(), notify(),and notifyAll() methods?
Correct
Incorrect
-
Question 8 of 20
8. Question
1 pointsSuppose 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?
Correct
Incorrect
-
Question 9 of 20
9. Question
1 pointsWhich class does not override the equals() and hashCode() methods, inheriting them directly from class Object?
Correct
Incorrect
-
Question 10 of 20
10. Question
1 pointsWhich collection class allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized?
Correct
Incorrect
-
Question 11 of 20
11. Question
1 pointsYou 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?
Correct
Incorrect
-
Question 12 of 20
12. Question
1 pointsWhich interface does java.util.Hashtable implement?
Correct
Incorrect
-
Question 13 of 20
13. Question
1 pointsWhich interface provides the capability to store objects using a key-value pair?
Correct
Incorrect
-
Question 14 of 20
14. Question
1 pointsWhich collection class allows you to associate its elements with key values, and allows you to retrieve objects in FIFO (first-in, first-out) sequence?
Correct
Incorrect
-
Question 15 of 20
15. Question
1 pointsWhich collection class allows you to access its elements by associating a key with an element’s value, and provides synchronization?
Correct
Incorrect
-
Question 16 of 20
16. Question
1 pointsWhich is valid declaration of a float?
Correct
Incorrect
-
Question 17 of 20
17. Question
1 pointsWhat is the numerical range of char?
Correct
Incorrect
-
Question 18 of 20
18. Question
1 pointsWhich of the following are Java reserved words?
run import default implement
Correct
Incorrect
-
Question 19 of 20
19. Question
1 pointsWhich of the following statements about the hashcode() method are incorrect?
The value returned by hashcode() is used in some collection classes to help locate objects. The hashcode() method is required to return a positive int value. The hashcode() method in the String class is the one inherited from Object. Two new empty String objects will produce identical hashcodes
Correct
Incorrect
-
Question 20 of 20
20. Question
1 pointsWhich two statements are true about comparing two instances of the same class, given that the equals() and hashCode() methods have been properly overridden?
If the equals() method returns true, the hashCode() comparison == must return true. If the equals() method returns false, the hashCode() comparison != must return true. If the hashCode() comparison == returns true, the equals() method must return true. If the hashCode() comparison == returns true, the equals() method might return true.
Correct
Incorrect
Quiz-summary
0 of 20 questions completed
Questions:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
Information
Computer Questions on Java Programming 4
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You have to finish following quiz, to start this quiz:
Results
0 of 20 questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 points, (0)
| Average score |
|
| Your score |
|
Categories
- Computer 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- Answered
- Review
-
Question 1 of 20
1. Question
1 pointsWhich of the following are true statements?
The Iterator interface declares only three methods: hasNext, next and remove. The ListIterator interface extends both the List and Iterator interfaces. The ListIterator interface provides forward and backward iteration capabilities. The ListIterator interface provides the ability to modify the List during iteration. The ListIterator interface provides the ability to determine its position in the List.
Correct
Incorrect
-
Question 2 of 20
2. Question
1 pointsWhich statement is true for the class java.util.ArrayList?
Correct
Incorrect
-
Question 3 of 20
3. Question
1 pointsWhich of the following statements is true?
Correct
Incorrect
-
Question 4 of 20
4. Question
1 pointsWhich statement is true?
Correct
Incorrect
-
Question 5 of 20
5. Question
1 pointsWhich statement is true about assertions in the Java programming language?
Correct
Incorrect
-
Question 6 of 20
6. Question
1 pointsWhich of the following statements is true?
Correct
Incorrect
-
Question 7 of 20
7. Question
1 pointsWhich of the following statements is true?
Correct
Incorrect
-
Question 8 of 20
8. Question
1 pointsWhich three statements are true?
Assertion checking is typically enabled when a program is deployed. It is never appropriate to write code to handle failure of an assert statement. Assertion checking is typically enabled during program development and testing. Assertion checking can be selectively enabled or disabled on a per-package basis, but not on a per-class basis. Assertion checking can be selectively enabled or disabled on both a per-package basis and a per-class basis.
Correct
Incorrect
-
Question 9 of 20
9. Question
1 pointsWhich statement is true?
Correct
Incorrect
-
Question 10 of 20
10. Question
1 pointsWhich four can be thrown using the throw statement?
Error Event Object Throwable Exception RuntimeException
Correct
Incorrect
-
Question 11 of 20
11. Question
1 pointsWhich statement is true?
Correct
Incorrect
-
Question 12 of 20
12. Question
1 pointsWhich statement is true?
Correct
Incorrect
-
Question 13 of 20
13. Question
1 pointsWhich two can be used to create a new Thread?
Extend java.lang.Thread and override the run() method. Extend java.lang.Runnable and override the start() method. Implement java.lang.Thread and implement the run() method. Implement java.lang.Runnable and implement the run() method. Implement java.lang.Thread and implement the start() method.
Correct
Incorrect
-
Question 14 of 20
14. Question
1 pointsWhich statement is true?
Correct
Incorrect
-
Question 15 of 20
15. Question
1 pointsWhich two statements are true?
Deadlock will not occur if wait()/notify() is used A thread will resume execution as soon as its sleep duration expires. Synchronization can prevent two objects from being accessed by the same thread. The wait() method is overloaded to accept a duration. The notify() method is overloaded to accept a duration. Both wait() and notify() must be called from a synchronized context.
Correct
Incorrect
-
Question 16 of 20
16. Question
1 pointsWhich statement is true?
Correct
Incorrect
-
Question 17 of 20
17. Question
1 pointsWhat will be the output of the program?
System.out.println(Math.sqrt(-4D));
Correct
Incorrect
-
Question 18 of 20
18. Question
1 pointsWhat will be the output of the program?
int i = (int) Math.random();
Correct
Incorrect
-
Question 19 of 20
19. Question
1 pointsWhich statement is true?
Correct
Incorrect
-
Question 20 of 20
20. Question
1 pointsWhich statement is true?
Correct
Incorrect