Jvdesktop2

If an object is visible to more than one thread, all reads or writes to that object's variables should be done through ____ methods.
Public
Synchronized
Protected
Private
Study the following Java statements: String s1= “Hello”; String s2= “Hello”; String s3= “Hello”
There is two strings are stored in memory of the program.
There is three strings are stored in memory of the program.
There is only one string is stored in memory of the program.
None of the others.
Select a correct statement.
Deadlock describes a situation where all threads do not access a shared resource.
Deadlock describes a situation where two or more threads are blocked forever, waiting for each other.
Deadlock describes a situation where all threads are put into a queue then they execute one after another.
None of the others.
Which of the following statements is true?
A thread must obtain the lock of the object it is trying to invoke the wait() method.
A thread must obtain the lock of the object it is trying to invoke the notify() method.
A thread must obtain the lock of the object it is trying to invoke a synchronized method.
A thread must obtain the lock of the object it is trying to invoke the notifyAll() method.
Which of the following methods causes a thread to release the lock of the object that it is currently holding?
Join()
Sleep()
Notify()
Wait()
The muti-threaded programming is used …….
When some tasks must be performed in a specific order.
When only one task is performed.
When some tasks must be performed concurrently.
None of the others.
The muti-threaded programming is used …….
When a task must be performed at a predictable time.
When a task must be performed at un-predictable time.
When a loop will be performed with a specific times.
None of the others.
Race condition may happen when:
More than one threads access the shared data of the application.
More than one threads access variables that are not declared as static.
More than one threads access variables that are not declared as volatile.
Any process that has more than one threads will absolutely have race condition.
To create a thread in Java, we can:
Create a subclass of the java.lang.Thread class and override the method run().
Create a subclass of the java.lang.Thread class and override the method start().
Create a subclass of the java.lang.Runnable class and override the method run().
Create a subclass of the java.lang.Runnable class and override the method start().
Select correct priority values of a thread (Integer values only):
From 0 to 10
From 1 to 5
From 0 to 5
From 1 to 10
Which of the following options is not a thread state?
Indelayed
Running
Sleeping
Ready
With respect to threads in Java, select a correct statement.
Developers can not access the current thread of the program.
If a thread is running and a condition is true, developers can not force a thread entering suspended state.
The main method (entry point of a Java program) is a default thread.
To force a thread entering sleeping state, a condition must be satisfied.
If an object may be accessed by some threads. These accesses should be done through ____ methods.
Public
Static
Protected
Synchronized
Select the best choice.
Deadlock describes a situation where all threads do not access a shared resource.
Deadlock describes a situation where two or more threads are blocked forever, waiting for each other.
Deadlock describes a situation where all threads are put into a queue then they execute one after another.
Deadlock describes a situation where all threads access a shared resource.
Race condition may happen if:
There are at least two threads in an application.
There is synchronized technique being used in the application.
There is more than one threads access the shared data of the application.
Which of the following options is not a valid thread priority property?
AVERAGE_PRIORITY
MAX_PRIORITY
MIN_PRIORITY
NORM_PRIORITY
When is a thread considered as a dead thread?
When the notify() method is called.
When stopThread() method is called.
When the run() method terminates.
When the yield() method is called.
When is a thread started running?
A thread is started immediately as soon as its start() method is called.
A thread is started immediately as soon as its run() method is called.
The Scheduler decides when a thread is started running.
A thread is started immediately as soon as an instance of a thread class is created
The Java Collection framework is implemented in the ...package.
Java.util.framework
Java.util.collection
Java.collection
None of the others.
Java.lang
In order to use the TreeSet class, the class that describes elements must implement the ... interface.
Java.lang.Comparing
Java.lang.Comparable
Java.util.Comparable
Java.util.treeset.Compare
None of the others
All of the numeric wrapper classes in the java.lang package are subclasses of the abstract class ...
Java.lang.Number
Java.lang.Integer
Java.lang.Object
Java.lang.Wrapper
None of the others
String S= "Hello"; String S2= new String("Java Program"); The String class describes an immutable chain of Unicode characters. Select a statement that causes an error.
S="Innovation";
S2=S.toUpperCase();
S+=S2;
None of the others.
All of these assignment statement.
Study the following code was implemented in the Hello class: static void print(Integer obj){ System.out.println(obj); } And it is used as: Integer obj= new Integer(5); int n= obj; //(1) Hello.print( n ); //(2) A ….. Operation is carried out at the code line (1) A ….. Operation is carried out at the code line (2)
Boxing, unboxing
Unboxing, boxing
Wrapping, un-wrapping
None of the others.
The top interface of the Java Collection Framework is…….
List
Map
Set
Collection
All of the others.
If we want to store a group of different elements in ascending order, the java.util.… class should be used.
SortedSet
Vector
ArrayList
HashMap
HashSet
An instance of the java.util.Scanner class can read data from the keyboard (1), a file (2), a string of characters (3). (1) is ……., (2) is ……., and (3) is ………..
True, true, true
True, true, false
True, false, true
True, false, false
None of the others
Given a string constructed by calling s = new String( "xyzzy" ), which of the calls modifies the string? (Choose one.)
S.append( "aaa" );
S.trim();
S.substring(3);
S.replace(‘z’, ‘a’);
S.concat(s);
None of the others.
Which one statement is true about the following code? 1. String s1 = "abc" + "def"; 2. String s2 = new String(s1); 3. if (s1 == s2) 4. System.out.println("== succeeded"); 5. if (s1.equals(s2)) 6. System.out.println(".equals() succeeded");
Lines 4 and 6 both execute.
Line 4 executes and line 6 does not.
Line 6 executes and line 4 does not.
Neither line 4 nor line 6 executes.
Which one statement is true about the following code fragment? (choose 1) 1. Import java.lang.Math; 2. Math myMath = new Math(); 3. System.out.println("cosine of 0.123 = " + myMath.cos( 0.123 ) );
Compilation fails at line 2.
Compilation fails at line 3.
Compilation succeeds, although the import on line 1 is not necessary. During execution, an exception is thrown at line 3.
Compilation succeeds. The import on line 1 is necessary. During execution, an exception is thrown at line 3.
Compilation succeeds and no exception is thrown during execution.
Suppose prim is an int and wrapped is an Integer. Which of the following are legal Java statements? (Choose one.)
Prim = wrapped;
Wrapped = prim;
Prim = new Integer( 9 );
Wrapped = 9;
All the others.
Suppose that obj1 and obj2 are objects and they belong to the same class. Study the semantics of following statements: (1) if (obj1==obj2) { } (2) if (obj1.equals( obj2 )) { }
(1) and (2) are different.
(1) and (2) are the same.
(1) uses deep comparison
(2) uses swallow comparison
A characteristic of generic technique is ......
It causes the code too complex.
It decreases the code readability.
It adds stability to the code by making more of bugs detectable at compile time.
None of the others.
Suppose that obj1 and obj2 are reference variables. The expression obj1==obj2 will execute ……
A deep comparison.
A swallow copy.
A swallow copy.
A swallow comparison.
One of the difference about Lists and Sets:
Lists can add primitive type only and Sets can add object references.
The number of items that can be added to Lists is limited; there is no such limitation for Sets.
A list can contain duplicate items but a set can not.
There is no difference.
Study the following Java statements: String S= “William, Bill is ill.”; int index1= S.indexOf(“ill”); int index2= S.lastIndexOf(“ill”); The value of index1 is ….. And index2 is ……
17, 1
1, 17
2, 18
18, 2
None of the others.
To traverse elements in a set, one after one element, the java.util.…….interface must be use.
Iterator
List
Set
Map
The _____ class is the ultimate ancestor of all Java classes.
Object
Class
Concept
AbstractObject
None of the others.
The Java Collection framework is implemented in the ______ package.
Java.collection
Java.framework
Java.util
Java.colectionframework
Java.lang
In order to use the TreeSet class, the class that describes elements must implement the ______ interface.
Java.util.Compare
Java.collection.Comparator
Java.tree.set.Element
Java.lang.Comparable
None of the others.
All of the numeric wrapper classes are subclasses of the abstract class ______.
Number
Double
Class
Integer
None of the others.
String S= “Hello”; String S2= new String(“Hello”); The String class describes an immutable chain of Unicode characters. Select a statement that causes an error.
S= S.toUpperCase();
S= S.toUpperCase();
Boolean b = (S==S2);
None of the others.
When invoking Math.random(), which of the following options might be the result?
The result is less than 1.0
The result is greater than 1.0
The result is equal 1.0
The result is from 1 to 100
Which of the following statements is true about Object class?
By default, the clone() method performs deep copy of an object
By default, the toString() method returns the name of the class
By default, the equals() method simply performs the == operator
By default, the toString() method returns the address of the class
Suppose that: - Your application has to read and write a string a lot of times. -Your application does not need to have multi threaded supports. - Performance is important. Which of the following classes will you choose to deal with string data type to achieve the above requirements?
StringBuffer
String
StringBuilder
StringPrinter
Suppose that a homogenous collection of objects, that belong the same type, are managed. Which of the following delarations is the best choice?
Java.util.Vector list;
Java.util.ArrayList list;
Java.util.TreeSet list;
Java.util.List list;
Which of the following options is correct?
Values stored in ArrayList are automatically sorted
Values stored in TreeSet are not allowed duplication
Values stored in Vector can be assessed through key-value pair.
None of the others
Which of the following options is not a method of the Scanner class?
NextValue()
Next()
NextInt()
NextDouble()
Which of the following collection cannot be used with Iterator class to traverse through elements?
Array
ArrayList
TreeSet
HashMap
Which of the following options is not a method of java.lang.Math Class?
Pow()
Floor()
Ceil()
Max()
None of the others
Which of the following classes is the ultimate ancestor of all Java classes?
Class
Concept
None of the others
Thing
{"name":"Jvdesktop2", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"if an object is visible to more than one thread, all reads or writes to that object's variables should be done through ____ methods., Study the following Java statements: String s1= “Hello”; String s2= “Hello”; String s3= “Hello”, Select a correct statement.","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}
Powered by: Quiz Maker