Vous êtes sur la page 1sur 91

Java

U01 - Q024
Select a characteristic that is not supported by the Java language?
procedure-oriented.
object-oriented.
security supported.
platform independent.
multi-threaded.
U01 - Q025
Select an incorrect identifier in Java.
&x
_23
$integer
Principle
_x_2

U01 - Q026
(1) A value variable contains data's value.
(2) A reference variable contains the address of data.
The statement (1) is ___, and the statement (2) is___
True, true
True, false
False, true
False, false













U01 - Q027
Select the output of the following Java code:
System.out.print(1>>10);
System.out.print(-1>>20);
0-1
00
1-1
Unpredictable output.
U01-Q001
The Java language supports:
Object-oriented programming.
Security.
Platform-independence.
Desktop and web applications.
All of the others.

U01-Q002
A Java source code will be compiled to!!
Java bytecode.
Machine code.
Assembly code.
Operation system code.
All of the others.
















U01-Q003
Study the following Java code:
int[] a= {1,2,3,4};
int b=1;
a[b]=b=3;
If the code is executed, the array contains values:
{ 1, 3, 3, 4 }
{ 1, 2, 3, 4 }
{ 1, 2, 3, 3 }
None of the others.
U01-Q006
If all three top-level elements occur in a source file, they must appear in which order?
Imports, package declarations, classes/interfaces/enums
Classes/interfaces/enums, imports, package declarations
Package declaration must come first; order for imports and class/interfaces/enum
definitions is not significant.
Package declaration, imports, class/interface/enum definitions.
Imports must come first; order for package declarations and class/interface/enum
definitions is not significant.
U01-Q007
How can you force garbage collection of an object?
Garbage collection cannot be forced.
Call System.gc().
Call System.gc(), passing in a reference to the object to be garbage-collected.
Call Runtime.gc().
Set all references to the object to new values (null, for example).









U01-Q008
What is the return type of the instanceof operator?
A reference.
A class.
An int.
A boolean.

U01-Q012
Comparison operators in Java language return .....
a Boolean value.
an integral value.
0 or 1
the character T or F.
one of the others.

U01-Q013
Suppose that a, and b are single dimensional arrays of integers, index1 and index2 are valid
indexes. Study the following statements:
(1) a[index1]= b[index2] ;
(2) a=b;
Both (1) and (2) are accepted.
(1) is accepted only.
(2) is accepted only.
Both (1) and (2) are not accepted.






U01-Q014
What is an identifier?
A word used by a developer to name a variable, a method, a class, or a label.
A Java keyword.
One of the words: public, private, protected, or default.
Java does not have the concept about identifiers.

U01-Q015
Select a correct Java declaration:
int $myInt;
int 3money;
int !cash;
int interface;
U01-Q016
A Java source code is a file with the file extension is !!.
.java
.class
.jar
.rar
U01-Q017
A Java source code will be compiled to the file with file extension is !!
.class
.java
.exe
.bat







U01-Q018
A reference variable can not be !..
an integral value.
a string of characters.
a student
an array of numbers.

U01-Q019
With respect to rules and conventions for naming variables in Java, select an incorrect
statement.
None of the others.
An indentifier can begin with a character.
An indentifier can begin with the dollar sign character.
An indentifier can begin with the underscore character.
The convention for naming a variable, however, is to always begin your variable
names with a letter, not "$" or "_". Additionally, the dollar sign character, by
convention, is never used at all.

U01-Q020
Select a wrong declaration:
None of the others.
long[] a ;
int _13=0;
int[] b;
int $class=0;
U01-Q021
Select a correct template of a Java source file.
package mypkg; import java.lang.*; class A { // class members }
import java.lang.*; package mypkg; class A { // class members }
import java.lang.*; class A { package mypkg; // class members }
None of the others.
U01-Q022
Which of the following is not a primitive data type in Java language?
String
byte
char
boolean
None of the others

U01-Q023
Suppose that the folowing Java code executes. What is the value of the result of variable.
int x= -7, y=3; int result= x%y;
-1
1
-2
2
None of the others.

U01-Q028
Which of the following declarations is not correct?
int x = 0A;
int x = 0x1c;
int x = 0x1C;
int x3 = 034;

U01-Q029
Which of the following commands is valid to execute a java byte-code file?
java myPackage.MyClassFile
java myPackage.MyClassFile.class
javac myPackage.MyClassFile
javac myPackage.MyClassFile.class

U01-Q030
Which of the following operators will shift all bit values to the right and fill the empty bits on
the left end with 0s?
>>>
>>
<<
<<<

U01-Q031
Consider the following operands and result:
11001110 (Operand 1: )
11110001(Operand 2)
00111111(Result)
Which of the following operators can create the above result?
XOR
AND
OR
NOT

U01-Q032
Which of the following options is not a Java characteristic?
Platform dependent
Object oriented
Distributed
Multi-threaded
U01-Q033
Which of the following commands is used to compile java source code into java bytecode?
javac
java
compileJava
cjava

U01-Q034
Files containing java bytecode have the extension as:
.class
.java
.bytecode
.byte

U01-Q035
Consider the following expression:
0000 0000 0000 0011 A 0000 0000 0000 0100 = B
If A is XOR operator, then B will be:
0000 0000 0000 0111
0000 0010 0000 0110
1110 0000 0000 0000
0000 0000 1111 0000

U01-Q036
Select an incorrect statement.
In a Java soure code, the first code line must be a class declaration.
In a Java source code, package declarations, if they are needed, must be put at
the beginning of a program.
The entry point of a Java program must be put in a class declaration.
The entry point of a Java program must be declared that it accepts an array of
strings as parameters.











U01-Q037
Study the following Java code:
int [] a= { 1, 2, 3, 4, 5 };
Select the best choice.
The variable a is a reference to a memory location that stores values.
The variable a is a value variable and its value is 1.
The variable a is primitive variable but its value is a group of integers.
None of the others is correct.

U01-Q038
Study the following Java code:
byte x= 5;
byte y= 5<<1;
Suppose that the above code is executed, the variable y will store a binary value as !..
00001010
00000101
00010100
None of the others

U01-Q039
Marks: --/1
Which of the following features Java does not suppor
Insecure
Distributed
Platform independent
Robust
U01-Q040
If we have a java class name as follows:
public class MyClass {}When the above class is compiled successfully, which of the
following files contains the java bytecode?
MyClass.class
MyClass.java
MyClass.bytecode
MyClass.byte

U01-Q041
Consider the following declaration:
int 3_my_var = 0x1c;
Select a correct statement:
The statement is incorrect because a variable declaration cannot start with a
number.
The statement is incorrect because the variable 3_my_var cannot be initialized
without creating instance of a class.
The statement is incorrect because the value 0x1c is not valid for int data type.

U01-Q042
Select the incorrect declaration.
double f = d32;
double f = 1.3D;
double f = 1.3E+21;
double f = 1.3D + 1.2d;
-->
<!-- question: 124 name: U02 - Q024

U02 - Q024
With respect to access modifier overridden, the right order is:
private, default, protected, public
default, private, protected, public
private, protected, default, public
public, protected, default, private





U02 - Q025
Which modifiers on instance variables will announce to the compiler that these variables are
not stored as part of its object's persistent state.
transient
public
native
volatile
synchronized
U02 - Q026
Select an operation which may cause an unchecked exception.
Accessing an element of an array.
Accessing data in a file.
Accessing a remote resource.
Accessing data in a database.
Controlling the state of a running thread.
U02 - Q027
Select the correct syntax for throwing an exception when declaring a method.
[Modifier] {Return type] Identifier (Parameters) throws TypeOfException
[Modifier] {Return type] Identifier (Parameters) throw TypeOfException
[Modifier] {Return type] Identifier (Parameters) {throw TypeOfException ;
[Modifier] {Return type] Identifier (Parameters) {throws TypeOfException ;
None of the others
U02-Q001
Select incorrect Java program entry point declarations.
(1) public static void main()
(2) public static void main(String [] args)
(3) public static void main(String args[])
(4) public static void main(string [] args)
(5) public static void main(String args)
1, 4, 5
1, 2, 3
2, 3, 4
3, 4, 5
All of the others.
U02-Q002
Select correct statements.
(1) A public member of a class can be accessed in all classes.
(2) A default member of a class can be accessed in all classes.
(3) A protected member of a class can be accessed in the package containing this class.
(4) A private member of a class can be accessed in the package containing this class.
1, 3
1, 2
1, 4
1, 2, 3
2, 3, 4
U02-Q003
Which of the following Java operations cause compile-time errors?
int m=5, n=7;
float x = m; //1
double y= n; //2
m = y; // 3
n = x; // 4
3, 4
1, 3
2, 4
1, 2, 3, 4
U02-Q004
If the following code is executed. What is the output?
int[] a= {1,2,3,4};
System.out.println(a[6]);
ArrayIndexOutOfBoundsException
A compile-time exception because they must be put in the try catch block.
0
A non-predictable value.




U02-Q005
If a Java source code contains an assert as an identifier and it will be compiled with JDK
version 1.4 or higher, !.
The option source 1.4 must be specified when it is compiled.
The option source 1.4 version must be specified when it is compiled.
The option enableassertion must be specified when it is run.
None of the others.
U02-Q006
Which of the following statements are true?
1)An abstract class can not have any final methods.
2)A final class may not have any abstract methods.
Only statement 1.
Only statement 2.
Both statement 1 and 2
None of the others.
U02-Q007
When a negative byte is cast to a long, what are the possible values of the result?
Positive value.
Zero.
Negative value.
All of the others.
U02-Q008
Suppose a method called finallyTest() method consisting of a try block, followed by a catch
block, followed by a finally block. Assuming the JVM doesnt crash and the code does not
execute a System.exit() call, under what circumstances will the finally block not begin to
execute?
The try block throws an exception, and the catch block also throws an exception.
The try block throws an exception that is not handled by the catch block.
The try block throws an exception, and the catch block calls finallyTest() in a way
that causes another exception to be thrown.
If the JVM doesn't crash and the code does not execute a System.exit() call, the
finally block will always execute.


U02-Q012
Java compiler allows !!.
Implicit widening conversions.
Implicit narrowning conversions
No conversions.
type casting only.
U02-Q013
Errors beyond the control of a program are called .........
Exceptions
Syntax errors
Assertions.
All of the others.
U02-Q014
What is NOT a unary operator?
/
--
~
++
U02-Q015
What is NOT a comparison operator?
>>
==
!=
instanceof



U02-Q016
A method in a super class is implemented using the default modifier, this method can not be
overridden in subclasses using the !.. modifier.
private
public
protected
default
U02-Q017
A !. method is implemented in a super class can not be overridden in derived classes.
final
private
default
protected
public
U02-Q018
The try! catch statements must be used to contain statements that !!
may cause checked exceptions.
may cause unchecked exceptions.
may cause compile-time errors.
may cause run-time errors.
U02-Q019
Which of the following modifiers is not an access modifier?
final
public
private
protected
None of the others



U02-Q020
Which of the following declarations is not correct?
private int i;
public protected String myString;
public class MyMoney { }
class ParserNum {}
U02-Q021
Which of the following statement is not correct about default access modifier?
To declare a variable that have default access modifier, we use the default
keyword. For example: default String myString;
A classs data and methods may be default, as well as the class itself.
A class that has default access modifier can be accessed by any class in the
same package.
A default method may be overridden by any subclass that is in the same package
as the super class.
U02-Q022
Which of the following statement is NOT correct about protected access modifier?
Only variables and methods may be declared as protected.
Different package sub-classes may override protected method of the super class.
Protected variables of a class can only be accessed by its sub-class in the same
package
None of the others.
U02-Q023
int x=2; //1
long z=3; //2
double t=5.4;//3
x=t; //4
z=x; //5
Which statement causes an error?
The statements (4) and (5).
The statement (4) only.
The statement (5) only.
None of the others.

U02-Q028
Which of the following declarations is not valid?
private int[] ar3 = new int[2]{1, 2};
private int ar2[] = new int[2];
private int ar1[] = {1,2,3,4};
private int[] ar = new int[]{1,2,3,4};
U02-Q029
Which of the following modifiers can assure that a class is not inherited by other classes?
final
abstract
transient
volatile

U02-Q030
The protected modifier cannot be applied to which of the following declarations?
static class A { }
static int x = 10;
static double = 23.2;
static string = 123;
U02-Q031
Which of the following modifiers is valid for a constructor?
private
static
synchronized
final



U02-Q032
Which of the following modifiers does not allow a method to be overridden?
final
abstract
public
protected
U02-Q033
Which of the following access modifiers does not allow a class to be accessed outsite its
package?
default
protected
public
final
U02-Q034
When handling exceptions, how many catch{} blocks can be used for one try{} block?
None of the others
1 only.
2 only
3 only
U02-Q035
Which of the following statements is correct?
For value types, narrowing conversion is not allowed.
For value types, widening conversion is not allowed.
A boolean can be converted to any other type.
None of the others




U02-Q036
The default access modifier in Java is !!.
None of the others.
public
private
static
protected
U02-Q037
The private and protected modifiers are not applied on .....
class
methods of a class
data members of a class
contructors of a class.
U02-Q038
Study the following Java code:
int n= 256;
byte x= (byte) n;
Suppose that the above code is executed, the value of the variable x is !!
0
25
258
128
None of the others
U02-Q039
Which of the following modifiers cannot be applied for a class?
protected
public
No modifier (default)
final


U02-Q040
Which of the following modifiers cannot be applied for interface and abstract classes?
protected
public
No modifier (default)
final
U02-Q041
Which of the following access modifiers makes a class cannot be inherited?
final
static
private
protected
U02-Q042
Which of the following modifiers makes a variable can be modified asynchronously?
volatile
synchronized
transient
native
-->
<!-- question: 163 name: U03 - Q024

U03 - Q024
The protected modifier can not be applied to...
Class
Object-level variables
Class-level variables
A method of a class
None of the others.


U03 - Q025
Which of the following statements is not a reason for using nested classes?
It supports a way for easily creating an object that is declared in an enclosing
class declaration.
It increases encapsulation.
Nested classes can lead to more readable and maintainable code.
It is a way of logically grouping classes that are only used in one place.
U03 - Q026
Select a correct statement about interfaces.
In its most common form, an interface is a group of related methods with empty
bodies.
An interface is a class that has method implementations with no data.
An interface is a class that has at least one abstract method.
An interface is an abstract class with no data.

U03 - Q027
Select a correct statement.
None of the others.
An abstract class can not contain a concrete method.
An interface can contain only one method implementation.
An abstract class must contain abstract methods only.
No data field can be declared in an abstract class.
U03-Q001
!!!. is applied in a class.
!!!. is applied in a class hierarchy.
Method overloading, method overriding.
Method overriding, method overloading.
Method expanding, method generalization.
Method generalization, method specification.
None of the others

U03-Q002
An abstract class !!!
can contain all concrete methods.
must contain at least one abstract method.
must contain all abstract method.
can not contain any data field.
U03-Q003
An interface can contain !!..
Constants.
Method implementations.
Inner classes.
All of the other.
U03-Q004
Suppose that the class A contains an inner class, named B. In a method of A, to access data
of a B object, !!
The B object must be referred by a reference declared in A.
The B object must be created in the main method of the program.
No restriction is examined because B is a subclass of A.
None of the others.


U03-Q006
Suppose x and y are of type TrafficLightState, which is an enum. What is the best way to test
whether x and y refer to the same constant? (Choose one.)
if (x == y)
if ( x.equals( y ) )
if ( x.toString().equals ( y.toString () ) )
if ( x.hashCode() == y.hashCode() )


U03-Q007
Suppose class X contains the following method:
void doSomething(int a, float b) { ! }
Which of the following methods may appear in class Y, which extends X? (Choose one.)
public void doSomething(int a, float b) { ! }
private void doSomething(int a, float b) { ! }
public void doSomething(int a, float b) throws java.io.IOException { ! }
private void doSomething(int a, float b) throws java.io.IOException { ! }
U03-Q008
Which of the following restrictions apply to anonymous inner classes? (Choose one) .
They must be defined inside a code block.
They may only read and write final variables of the enclosing class.
They may only call final methods of the enclosing class.
They may not call the enclosing class synchronized methods.
U03-Q009
Which of the following may override a method whose signature is void xyz(float f)?
private int xyz(float f)
public void xyz(float f)
private void xyz(float f)
public int xyz(float f)
U03-Q012
We can ......
All of the others.
declare an object that belongs to an abstract class.
declare an object that belongs to an interface.
declare an object that belongs to a class then initialize it as an subclass object.




U03-Q013
In a subclass, a calling to a constructor of superclass .......
must be the first line in a constructor of the subclass.
can be let at somewhere in a constructor of the subclass.
must be let at the first line of subclass declaration.
can be presented with the syntax: SubClass (parameters): super(parameters) {
! }
U03-Q014
What does the default modifier mean?
It provides access to any class in the same package.
It means as the private modifier.
I can provide access to any class in the different packages which is a super
class.
It means as the protected modifier.
U03-Q015
Which statement is correct about protected modifier?
Only variables and methods may be declared as protected members.
It means as the private modifier.
It means as the default modifier.
The protected modifier can only provide accessing to the members of the class
itself.
U03-Q016
In Java, .....
All of the others.
we can create objects that belong to an abstract class if all abstract methods are
implemented in object declarations.
We can not create objects that belong to an abstract class using standard syntax
of object declaration.
We use the interface keyword to declare an interface.



U03-Q017
Suppose that A, B, C are classes in which B is a subclass of A. Study the following
declarations:
A objA;
B objB;
C objC;
Select a valid statement.
objA=objB;
objA=objC;
objB=objC;
objB=objA;
objC=objA;
objC=objB;
U03-Q018
The re-use code ability is a result of the !! in OOP.
inheritance
encapsulation
polymorphism
aggregation
U03-Q019
Real-world objects share two characteristics: They all have state and behavior. Software
objects are conceptually similar to real-world objects: they too consist of state and related
behavior. A software object stores its state in _____ and exposes its behavior through
______.
fields, methods
methods, fields
classes, objects
None of the other choices





U03-Q020
Object-oriented programming allows classes to ____ commonly used state and behavior from
other classes. In Java, the ____ keyword is used to declare a subclass of another class.
inherit, extends
use, extends
have, extend
use, implements
None of the others
U03-Q021
The term "instance variable" is another name for ____, and the term "class variable" is
another name for _____.
non-static field, static field
static field, non-static field
public field, protected field
default field, public field
None of the others.
U03-Q022
Which of the following statements is not a reason for using nested classes?
None of the others.
It is a way of logically grouping classes that are only used in one place.
It increases encapsulation.
Nested classes can lead to more readable and maintainable code.

U03-Q023
Select correct statement about interfaces.
In its most common form, an interface is a group of related methods with empty
bodies.
An interface is a class that has a method having empty body.
An interface is a class that has at least one abstract method.
An interface is an abstract class.
None of the others
U03-Q028
In OOP, which of the following statements is correct in terms of cohesion?
Each method should perform one specific task only.
Classes in a program should not depend too much on each other.
In a class, there should not be too many functions.
Each function should contain as less code as possible
U03-Q029
Consider the following piece of code:
import javax.swing.JTextField;
class Counter {
int count=0;
void increment() { count++; }
void reset() { count=0; }
JTextField txt= new JTextField();
void display() {
// display the count
txt.setText(Counter: + count);
}
}
The bove code is an example of ......
tight coupling
loose coupling
high cohesion
low cohesion
U03-Q030
You are assigned a job that you need to buy a lock to replace the old one in your company. A
lock-set includes 2 components: a lock and a key. Each key can only fit one lock.
A key and a lock is an example of !
tight coupling
loose coupling
high cohesion
low cohesion




U03-Q031
Which of the following statements is not true in terms of overriding methods?
An overriding method (in sub-class) can throw any checked exception (or
subclasses of those exceptions) that are not declared in the overridden method (in
supper-class).
A parent class method may be overridden once at most in each its subclass.
An overriding method must return exactly the same type as the method it
overrides.
An overriding method must not be less accessible than the method it overrides.
U03-Q032
Which of the following statements is correct about overloading methods?
Overloading methods are implemented in the same class
Overloading methods are implemented with different implementation
Overloading methods are implemented in different classes
None of the others
U03-Q033
Which of the following statements is correct about overridding methods?
Each parent class method may be overridden once at most in any one subclass.
An overriding method does not need to return exactly the same type as the
method it overrides.
An overriding method does not need to have the same signatures as the method
it overrides.
An overriding method can be less accessible than the method it overrides.
U03-Q034
Which of the following options we try to achieve while designing object oriented software?
Low coupling
Low cohesion
High coupling
High coupling and low cohesion




U03-Q035
Which of the following statements is correct?
Outer class must contain an instance of the inner class before accessing
members of the inner class.
Inner class must contain an instance of the outer class before accessing
members of the outer class.
Inner class must be a static class
Inner class must be a non-static class
U03-Q036
A software object stores its state in ..! and exposes its behaviors through !...
Fields, methods
Methods, fields
Classes, objects
None of the others
U03-Q037
In a class, non static fields are called as !!.., and static fileds are called as !!.
Instance variables, class variables
Class variables, instance variables
public fields, protected fields
Default fields, public fields
None of the others
U03-Q038
With respect to Java, select a correct statement about interfaces.
None of the others.
An interface is a class that has a method having empty body.
An interface is a class that has at least one abstract method.
An interface is an abstract class.


U03-Q039
Select a correct statement about encapsulation implementation in OOP:
All of the others
Data of a class should be hidden from the outside.
All behavior should be accessed only via methods.
A method should have a boundary condition.
U03-Q040
Consider the following class:
class MyClass {
void myFunction(){}
int myFunction() {return 0;}
}
Select a correct statement about MyClass.
MyClass has a compile error.
MyClass has implemented overriding methods
MyClass has implemented overloading methods
MyClass has implemented inheritance

U03-Q041
Which of the following methods can be used to call a constructor of a father class from the
sub-class?
super()
father()
callSuper()
callFather()
U03-Q042
Select an incorrect statement about inner classes:
An inner class cannot be declared inside a method of the outer class.
There are 2 types of nested class: Static Nested classes, Inner classes (non-
static classes).
Outer class must contain an instance of the inner class then accesses member of
this instance.

U04 - Q024
... exist within a ... Every ... has at least one...
Threads, process, process, thread
Processes, thread, thread, process
Threads, process, thread, process
Processes, thread, process, thread
U04 - Q025
Multithreaded execution is an essential feature of the Java platform. Every application has at
least ... thread(s).
None of the others
Two
Three
Four
U04 - Q026
An application that creates an instance of Thread must provide the code that will run in that
thread. Select a correct way to do this.
Provide a Runnable object. The Runnable object is passed to the Thread
constructor.
All things are creating a Runnable object.
All things are creating a java.lang.Thread object.
All of the others.
U04 - Q027
if an object is visible to more than one thread, all reads or writes to that object's variables
should be done through ... methods.
None of the others
public
private
protected



U04-Q001
Select correct statement(s).
(1) A process has a self-contained execution environment.
(2) A sub-thread has a self-contained execution environment.
(3) Programmers can schedule sub-threads of a program.
1
1, 2
1, 2, 3
2, 3
2
None of the others.
U04-Q002
Two sub-threads of a program may not need synchronized if !!
They do not access any common resource.
They access common resources.
A thread waits a lock that is held by another.
None of the others.
U04-Q003
Select correct statement(s):
(1) A thread can be an instance of the java.lang.Thread class.
(2) A thread can be an instance of a subclass of the java.lang.Thread class.
(3) An instance of a class which implements the java.lang.Runnable can supply the
executable code for a thread object.
1
2
3
1, 2
1, 3
1, 2, 3




U04-Q004
(1) An object having synchronized methods is called a( an ) !!!.
(2) The !!! technique can be applied with a hope that a deadlock situation may not occur
in a program .
(3) The sleep(! ) method of the java.lang.Thread class accepts a argument that specifies a(
an ) !!!!.
Monitor, wait-notify, specific period of time.
Synchronizer, sleeping, specific period of time.
Examiner, wait, father thread
Monitor, NotifyAll, executing program.
None of the others
U04-Q006
A threads run() method includes the following lines:
1. try {
2. sleep(100);
3. } catch (InterruptedException e) { }
Assuming the thread is not interrupted, which one of the following statements is correct?
The code will not compile, because exceptions cannot be caught in a threads
run() method.
At line 2, the thread will stop running. Execution will resume in, at most, 100
milliseconds.
At line 2, the thread will stop running. It will resume running in exactly 100
milliseconds.
At line 2, the thread will stop running. It will resume running some time after 100
milliseconds have elapsed.
U04-Q007
A monitor called mon has 10 threads in its waiting pool; all these waiting threads have the
same priority. One of the threads is thr1. How can you notify thr1 so that it alone moves from
the Waiting state to the Ready state? (Choose one).
Execute notify(thr1); from within synchronized code of mon.
Execute mon.notify(thr1); from synchronized code of any object.
Execute thr1.notify(); from synchronized code of any object.
Execute thr1.notify(); from any code (synchronized or not) of any object.
You cannot specify which thread will get notified.



U04-Q008
Which of the following methods in the Thread class are deprecated? (Choose one)
suspend() and resume()
wait() and notify()
start() and stop()
sleep() and yield()




U04-Q009
Which of the following statements about threads is true? (Choose one.)
Every thread starts executing with a priority of 5.
Threads inherit their priority from their parent thread.
Threads are guaranteed to run with the priority that you set using the setPriority()
method.
Thread priority is an integer ranging from 1 to 100.
U04-Q012
As soon as a Java thread is created, it enters the !!.. state.
ready
waiting
suspended
sleeping
U04-Q013
Thread synchronization should be implemented if .....
Threads access common resources.
Each thread accesses separate resources.
Threads run concurrently.
All of the others.
U04-Q014
Which of the following statements is correct about Thread?
During its lifetime, a thread spends some time executing and some time in any of
non-executing states.
The call of threads start() method causes the thread to run immediately.
A thread cannot execute its own run() method.
A thread is marked as eligible to run when it is an object of the Thread class even
when its start() method is not called yet.
U04-Q015
Which of the following statement is correct about Thread?
When the run() method of a thread returns, that thread is put into ready state.
We cannot call other methods (excepts start() and run()) of a dead thread.
We can restart a dead thread by calling its start()or run() methods.
We cannot restart a dead thread by calling its start()or run() methods.
U04-Q016
Which method is NOT a member the Object class?
notify()
notifyAll()
wait()
waitAll()
U04-Q017
When a thread begins waiting an IO operation, it enters the !.. state.
blocked
ready
sleep
suspended




U04-Q018
In multi-processing system,
Each process usually accesses its own data.
A process must access data in others.
All process must access common data allocated by operating system only.
All process have common executable environment.
U04-Q019
_____ exist within a ____ - every _____ has at least one.
Theads, process, process.
Processes, thread, thread
Threads, process, thread
Processes, thread, thread
U04-Q020
Multithreaded execution is an essential feature of the Java platform. Every application has at
least _____ thread(s).
one
two
three
None of the others.
U04-Q021
An application that creates an instance of Thread must provide the code that will run in that
thread. Select a correct way to do this.
Provide a Runnable object. The Runnable object is passed to the Thread
constructor.
All things are creating a Runnable object.
All things are creating a Thread object.
None of the others.



U04-Q022
if an object is visible to more than one thread, all reads or writes to that object's variables
should be done through ____ methods.
synchronized
public
protected
private
U04-Q023
Select a correct statement.
Deadlock describes a situation where two or more threads are blocked forever,
waiting for each other.
Deadlock describes a situation where all threads do not access a shared
resource.
Deadlock describes a situation where all threads are put into a queue then they
execute one after another.
None of the others.
U04-Q028
Which of the following statements is true?
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 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 the notifyAll()
method.
U04-Q029
Which of the following methods causes a thread to release the lock of the object that it is
currently holding?
wait()
join()
sleep()
notify()

U04-Q030
The muti-threaded programming is used !!.
when some tasks must be performed concurrently.
when some tasks must be performed in a specific order.
when only one task is performed.
None of the others.
U04-Q031
The muti-threaded programming is used !!.
when a task must be performed at un-predictable time.
when a task must be performed at a predictable time.
When a loop will be performed with a specific times.
None of the others.
U04-Q032
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.
U04-Q033
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().




U04-Q034
Select correct priority values of a thread (Integer values only):
From 1 to 10
From 0 to 10
From 1 to 5
From 0 to 5
U04-Q035
Which of the following options is not a thread state?
Indelayed
running
sleeping
ready
U04-Q036
With respect to threads in Java, select a correct statement.
The main method (entry point of a Java program) is a default thread.
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.
To force a thread entering sleeping state, a condition must be satisfied.
U04-Q037
if an object may be accessed by some threads. These accesses should be done through
____ methods.
Synchronized
public
static
protected




U04-Q038
Select the best choice.
Deadlock describes a situation where two or more threads are blocked forever,
waiting for each other.
Deadlock describes a situation where all threads do not access a shared
resource.
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.
U04-Q039
Race condition may happen if:
There is more than one threads access the shared data of the application.
There are at least two threads in an application.
There is synchronized technique being used in the application.
U04-Q040
Which of the following options is not a valid thread priority property?
AVERAGE_PRIORITY
MAX_PRIORITY
MIN_PRIORITY
NORM_PRIORITY
U04-Q041
When is a thread considered as a dead thread?
When the run() method terminates.
When the notify() method is called.
When stopThread() method is called.
When the yield() method is called.




U04-Q042
When is a thread started running?
The Scheduler decides when a thread is 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.
A thread is started immediately as soon as an instance of a thread class is
created.
U05 - Q024
The Java Collection framework is implemented in the ...package.
None of the others.
java.util.framework
java.util.collection
java.collection
java.lang
U05 - Q025
In order to use the TreeSet class, the class that describes elements must implement the ...
interface.
java.lang.Comparable
java.lang.Comparing
java.util.Comparable
java.util.treeset.Compare
None of the others
U05 - Q026
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

U05 - Q027
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.
None of the others.
S="Innovation";
S2=S.toUpperCase();
S+=S2;
All of these assignment statement.
U05-Q001
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)
Unboxing, boxing
Boxing, unboxing
Wrapping, un-wrapping
None of the others.
U05-Q002
The top interface of the Java Collection Framework is!!.
Collection
List
Map
Set
All of the others.



U05-Q003
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

U05-Q004
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
U05-Q006
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.




U05-Q007
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.
U05-Q008
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.
U05-Q009
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.



U05-Q012
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
U05-Q013
A characteristic of generic technique is ......
It adds stability to the code by making more of bugs detectable at compile time.
It causes the code too complex.
It decreases the code readability.
None of the others.
U05-Q014
Suppose that obj1 and obj2 are reference variables. The expression obj1==obj2 will execute
!!
a swallow comparison.
a deep comparison.
a swallow copy.
a deep copy.
U05-Q015
One of the difference about Lists and Sets:
A list can contain duplicate items but a set can not.
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.
There is no difference.



U05-Q016
Study the following Java statements:
String s1= Hello;
String s2= Hello;
String s3= Hello;
There is only one string is stored in memory of the program.
There is two strings are stored in memory of the program.
There is three strings are stored in memory of the program.
None of the others.
U05-Q017
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 !!
1, 17
17, 1
2, 18
18, 2
None of the others.
U05-Q018
To traverse elements in a set, one after one element, the java.util.!!.interface must be use.
Iterator
List
Set
Map
U05-Q019
The _____ class is the ultimate ancestor of all Java classes.
Object
Class
Concept
AbstractObject
None of the others.

U05-Q020
The Java Collection framework is implemented in the ______ package.
java.util
java.collection
java.framework
java.colectionframework
java.lang
U05-Q021
In order to use the TreeSet class, the class that describes elements must implement the
______ interface.
java.lang.Comparable
java.util.Compare
java.collection.Comparator
java.tree.set.Element
None of the others.
U05-Q022
All of the numeric wrapper classes are subclasses of the abstract class ______.
Number
Double
Class
Integer
None of the others.
U05-Q023
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 + Chan;
boolean b = (S==S2);
None of the others.

U05-Q028
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
U05-Q029
Which of the following statements is true about Object class?
By default, the equals() method simply performs the == operator
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 toString() method returns the address of the class
U05-Q030
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?
StringBuilder
StringBuffer
String
StringPrinter
U05-Q031
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.ArrayList list;
java.util.Vector list;
java.util.TreeSet list;
java.util.List list;


U05-Q032
Which of the following options is correct?
Values stored in TreeSet are not allowed duplication
Values stored in ArrayList are automatically sorted
Values stored in Vector can be assessed through key-value pair.
None of the others
U05-Q033
Which of the following options is not a method of the Scanner class?
nextValue()
next()
nextInt()
nextDouble()
U05-Q034
Which of the following collection cannot be used with Iterator class to traverse through
elements?
Array
ArrayList
TreeSet
HashMap
U05-Q035
Which of the following options is not a method of java.lang.Math Class?
None of the others
pow()
floor()
ceil()
max()




U05-Q036
Which of the following classes is the ultimate ancestor of all Java classes?
None of the others
Class
Concept
Thing
U05-Q037
In Java Collection framework, which of the following pre-defined classes allow an element
can be accessed through its index?
java.util.ArrayList
java.util.TreeMap
java.util.TreeSet
java.util.HashSet
U05-Q038
In which situation are generic collections used?
The collection contains homogenous elements.
) The collection contains elements which belong to some classes.
The collection contains elements which belong to exactly two classes.
None of the others
U05-Q039
Which of the following Java lists that allows data is stored in sorted order, and also, no
duplicate data is allowed?
TreeSet
ArrayList
Vector
LinkedList



U05-Q040
You are required to build a Java application. Your application uses Vector to store data. Each
time elements, taken from the vector, should be displayed to users in a random order.
Which of the following methods can be used to achieve the above task?
Collections.shuffle()
Collections.random()
Collections.radomElement()
Collections.mix()
U05-Q041
You are required to validate an email string taken from users. A valid email form should be
email@address.com.
Select a correct pattern that can be used to validate email input:
"^\w+@\w+[.]\w+$"
"^\w+@\w+.\w+$"
"^\w?@\w+[.]\w+$"
U05-Q042
If we use Math.random() method to random a number, which of the following numbers will
never be appeared?
1.0
0.2
0.1
0.4
-->
<!-- question: 389 name: U06 - Q024

U06 - Q024
An I/O Stream represents an input source or an output destination. A stream can represent...
All of the other choices.
A disk file.
A string of characters.
Data from network.
Another program

U06 - Q025
The java.io.ObjectInputStream class is a subclass of the ...class.
java.io.InputStream
java.io.Stream
java.io.Object
java.io.ObjectInput
java.io.ByteSream
U06 - Q026
Select a correct statement.
All of the others.
DataInputStream, DataOutputStream are binary streams.
PrintWriter, BufferedReader are not binary streams.
ObjectInputStream, ObjectOutputStream are not text streams.
U06 - Q027
When reading objects from an object stream,
we usually use an explicit casting.
The compiler automatically identifies the class of the object.
The compiler will automatically use a conversion.
No casting is needed.
U06-Q001
Select correct statement(s).
(1) All byte stream classes are descended from the InputStream and OutputStream classes .
(2) All character stream classes are descended from the Reader and Writer classes .
(3) All byte stream classes are descended from the Reader and Writer classes .
(4) All character stream classes are descended from the InputStream and OutputStream
classes .
1, 2
1, 4
2, 3
None of the others.


U06-Q002
To read data from a text file using the line-by-line accessing. The right order of object
creations is:
File FileReader - BufferedReader
File BufferedReader
File FileInputStream
File BufferedReader - FileReader
File FileReader

U06-Q003
To write objects to an object file. The right order of object creations is:
FileOutputStream- ObjectOutputStream
File ObjectOutputStream FileOutputStream
File - ObjectOutputStream- Writer
FileReader ObjectOutputStream
None of the others
U06-Q004
(1) The java.io!. class makes it easier to write platform-independent code that examines and
manipulates files.
(2) The java.io.!. class makes it easier to write platform-independent code that examines
and manipulates folders.
File, File
File, Folder
File, Directory
File, Container
None of the others
U06-Q006
How do you use the File class to list the contents of a directory? (Choose one.)
String[] contents = myFile.list();
File[] contents = myFile.list();
StringBuilder[] contents = myFile.list();
The File class does not provide a way to list the contents of a directory.
U06-Q007
Which of the following is true? (Choose one.)
Readers have methods that can read and return floats and doubles.
Readers have methods that can read and return floats.
Readers have methods that can read and return doubles.
Readers have methods that can read and return ints.
None of the others





U06-Q008
Given the following class:
public class Xyz implements java.io.Serializable {
public int iAmPublic ;
private int iAmPrivate ;
static int iAmStatic ;
transient int iAmTransient ;
}
Assuming the class does not perform custom serialization, which fields are written when an
instance of Xyz is serialized?
iAmPublic, iAmPrivate
iAmPublic
iAmStatic, iAmTransient
iAmTransient
U06-Q009
Which of the following are true?
System.out has a println() method.
System.out has a format() method.
System.err has a println() method.
System.err has a format () method.
All of the others.
U06-Q012
When we access a file or directory metadata such as name, path, last modified time,! We
should use the ........... class.
java.io.File
java.io.FileReader
java.io.FileWriter
java.io.Directory
java.io.Folder
U06-Q013
Suppose that you want reading some records stored in a text file, classes in the java.io
package can be used:
(1) File, (2) FileInputStream, (3) RandomAccessFile,
(4) FileReader (5) BufferedReader, (6) PrintWriter
(1), (4), (5)
(1), (2), (3)
(1), (3), (6)
All of them.
U06-Q014
Consider the following declaration:
RandomAccessFile(File file, String mode)
If the mode is declared as rws, what does it mean?
It means the file can be opened for both reading and writing, and any changes to
the files content or metadata will take place immediately.
It means the file can be opened for both reading and writing, and any changes to
the files content, but not its metadata, will take place immediately.
It means the file can be opened for reading only.
It means the file can be opened for appending data only.






U06-Q015
Consider the following declaration:
RandomAccessFile(File file, String mode)
If the mode is declared as rwd, what does it mean?
It means the file can be opened for both reading and writing, and any changes to
the files content, but not its metadata, will take place immediately.
It means the file can be opened for both reading and writing, and any changes to
the files content or metadata will take place immediately.
It means the file can be opened for reading only.
It means the file can be opened for appending data only.
U06-Q016
Two topmost abstract classes for character streams are !... and !!.
java.io.Reader, java.io.Writer
java.io.InputStream, java.io.OutputStream
java.io.ObjectInputStream, java.io.ObjectOutputStream
None of the others.
U06-Q017
The !!. class makes utilities to write platform-independent code that examines and
manipulates folders.
java.io.File
java.io.Folder
java.io.Directory
None of the others.

U06-Q018
To read/write objects from/to a file as object streams, the class declaration of these objects
must implement the marker interface !..
java.io.Serializable
java.io.Serialization
java.lang.Serialization
java.lang.Serializable
java.io.Stream


U06-Q019
An I/O Stream represents an input source or an output destination. A stream can represent
____.
disk files
devices
other programs
memory arrays
All of the others
U06-Q020
In _____ binary streams, a read/write data unit is _______.
low-level, general-format data
high-level, byte
low-level, primitive data
None of the others.
U06-Q021
The ObjectInputStream is a subclass of the _____ class.
InputStream
Reader
Writer
FileReader
FileInputStream
U06-Q022
Select a correct statement.
All of the others.
DataInputStream, DataOutputStream are binary streams.
PrintWriter, BufferedReader are text streams.
ObjectInputStream, ObjectOutputStream are binary streams.


U06-Q023
When reading objects from an object stream, we usually use _____.
an explicit class casting
an implicit class conversion
no type changes
None of the others.
U06-Q028
Which of the following options is not a valid declaration of the RandomAccessFile class?
RandomAccessFile r = new RandomAccessFile(file.txt, w);
RandomAccessFile r = new RandomAccessFile(file.txt, rw);
RandomAccessFile r = new RandomAccessFile(file.txt, rws);
RandomAccessFile r = new RandomAccessFile(file.txt, rwd);
U06-Q029
In order to allow an object can be serialized into a file, which of the following interfaces needs
to be implemented?
java.io.Serializable
java.io.Serialized
java.io.Synchronizable
java.io.Synchronized
U06-Q030
You are required to write a program that stores data retrieved from users to a text file. The
data must be stored line by line and in Unicode format. Which of the following classes is the
best choice for storing tasks?
java.io.PrintWriter
java.io.File
java.io.RandomAccessFile
java.io.FileInputStream



U06-Q031
Which of the following classes is not an abstract class?
None of the others.
java.io.Reader
java.io.Writer
java.io.InputStream
java.io.OutputStream
U06-Q032
We have the constructor of the java.io.RandomAccessFile class as follows:
RandomAccessFile(String file, String mode)
Which of the following options is not a valid value for the mode option?
w
r
rw
rws
U06-Q033
Which of the following classes do not directly read from/write to input/output devices such as
disk files or sockets; rather, they read from/write to other streams?
DataInputStream/ DataOutputStream
FileInputStream /FileOutputStream
RandomAccessFile
FileReader/FileWriter
U06-Q034
Which of the following classes can be used to serialize an object into a file?
ObjectOutputStream
DataOutputStream
FileOutputStream
FileWriter



U06-Q035
Which of the following methods of the File class can be used to get the size of a given file?
length()
size()
getFileSize()
getFileLength()
U06-Q036
A stream can represent !.
a disk file.
a device
a memory array
All of the others.
U06-Q037
The ObjectInputStream is a subclass of the !!!. class.
None of the other.
Reader
Writer
FileWriter
U06-Q038
When accessing objects in an object stream, we must !!.
Access them using a suitable program.
Use a text editor.
Use binary code editor.
None of the others.
U06-Q039
Which of the following features is not supported by java.io.RandomAccessFile class?
Reading and writing data from and to a socket
Get the file pointer
Seeking to any position within a file
Reading and writing data from and to a file
U06-Q040
You use java.io.RandomAccessFile to manipulate a file name myFile.txt. Which of the
following statements is valid if you want to open the file myFile.txt in a writing-only mode?
There is no writing-only mode in java.io.RandomAccessFile class.
RandomAccessFile raf = new RandomAccessFile(myFile.txt, w);
RandomAccessFile raf = new RandomAccessFile(myFile.txt, wd);
RandomAccessFile raf = new RandomAccessFile(myFile.txt, ws);
U06-Q041
Which of the following classes are exclusively designed for writing and reading Unicode
characters?
FileReader/ FileWriter
DataInputStream/ DataOutputStream
FileInputStream/ FileOutputStream
RandomAccessFile
U06-Q042
Which of the following classes can be used for writing and reading objects (serializing/de-
serializing) from and to a file?
ObjectInputStream/ObjectOutputStream
FileReader/ FileWriter
DataInputStream/ DataOutputStream
FileInputStream/ FileOutputStream
-->
<!-- question: 202 name: U07 - Q024

U07 - Q024
Which method do you use to enable or disable components such as JButtons?
None of the others
enable()
disable()
editable()
setEditable()

U07 - Q025
A component that lets the user pick a color.
JColorChooser
JColorPicker
JColorSelector
JColorMaker
JColorMixer
U07 - Q026
The container has one component that should take up as much space as possible. Which
layouts that easily deal with this situation should be selected?
GridLayout
FlowLayout
CardLayout
Null Layout
GridBagLayout
U07 - Q027
Which component can display an image, but cannot get focus?
JLabel
JTextField
JButton
JListBox
JPasswordField
U07-Q001
Select correct statement(s).
(1) Swing is part of the Java Foundation Classes and provides a rich set of GUI components.
(2) Before you think about what your GUI will look like , its important to think about what it
will.
1, 2
1
2
None of the others.

U07-Q002
Select correct statement(s).
(1) The Swing's list component (JList) can display text only.
(2) The Swings button (JButton) can not contain an image.
(3) The Swings label (JLabel) can present an image.
3
2, 3
1, 3
1
None of the others
U07-Q003
Which of the following layout manager will present components with the same size.
java.awt.GridLayout
java.awt.FlowLayout
java.awt.CardLayout
java.awt.BorderLayout
None of the others
U07-Q004
Select correct statement(s).
(1) 12 buttons can not be added to a container which is assigned to a grid layout 2x5.
(2) If 2 components are added to the center region of a border-layout container, they will be
seen by user as side-by-side components.
None of the others.
2
1
2, 1






U07-Q006
Which is four-step approach to help you organize your GUI thinking. (Choose one.)
Identify needed components.
Isolate regions of behavior.
Sketch the GUI.
Choose layout managers
Choose layout managers.
Identify needed components.
Isolate regions of behavior.
Sketch the GUI.
Identify needed components.
Choose layout managers.
Isolate regions of behavior.
Sketch the GUI.
None of the others.
U07-Q007
The Swing component classes can be found in the ________________ package.
javax.swing
java.swing
javax.swings
javax.Swing
U07-Q008
A _____ dialog prevents user input to other windows in the application unitl the dialog is
closed.
Modal
Non-Modal
unmodel
None of the others.
U07-Q009
The border layout resizes the ______ components to fill the remaining centre space.
West
South
Center
East
Middle
U07-Q010
The container can display three completely different components at different times,
depending perhaps on user input or program state. Even if the components sizes differ,
switching from one component to the next shouldnt change the amount of space devoted to
the component.
GridLayout
FlowLayout
CardLayout
GridBagLayout
U07-Q011
Select incorrect statement about FlowLayout. (choose 1)
The Flow layout manager always honors a components preferred size.
The Flow layout manager arranges components in horizontal rows.
It is the default layout manager type for JFrame.
The Flow layout manager fits as many components as possible into the top row
and spills the remainder into a second row. The components always appear, left to
right, in the order they were added to their container.
U07-Q012
In a complex GUI containing a lot of components and user must be select some data in a
group of specific data, the component should be used is .......
combo box
a panel containing some checkboxes.
a list box
a panel containing some radio-buttons.
One of the others.
U07-Q013
We can replace a card layout of a container with ..........
tabbed pane
flow layout
border layout
grid layout


U07-Q014
Select an incorrect statement.
A combobox can contain strings only.
A node on a javax.swing.JTree object can be a view of an arbitrary object.
A cell in a javax.swing.JTable object can be a view of an arbitrary object.
We should wrap some radiobuttons in a button group.
U07-Q015
In Swing, what is the role of the components model?
It is responsible for the data that the component presents to the users.
It is responsible for the region of the screen dedicated to show something to the
user.
It is responsible for taking in user request and then modifies those requests.
It is a model component that we can base on that to create a similar component.
U07-Q016
Suppose that we have a combobox that contains a list of data. The combobox can only
display to the user one item at a time. In term of Model-View-Controller, which of the following
statement is correct?
The list of data of the combobox can be considered as a representative of the
Model.
The list of data of the combobox can be considered as a representative of the
View.
The list of data of the combobox can be considered as a representative of the
Controller.
U07-Q017
Which of the following statements is correct about Flow layout?
The Flow layout arranges frames in horizontal rows.
The Flow layout arranges frames in vertical columns.
The Flow layout arranges components in horizontal rows.
The Flow layout arranges components in vertical columns.



U07-Q018
Which of the following statement is correct about Card layout?
Card layout arranges components in time rather than in space.
Card layout arranges each component as a card.
Card layout arranges component by dividing frame into spaces called card.
Card layout arranges components in squares.
U07-Q019
Which method do you use to enable and disable components such as JButton s?
setEnable
enable
activate
setActive
None of the others.


U07-Q020
A component that lets the user pick a color.
color chooser
color picker
color selector
color dialog
U07-Q021
The container has one component that should take up as much space as possible. Which
layouts that easily deal with this situation should be selected?
BorderLayout or GridLayout
GridLayout
BorderLayout
FlowLayout
CardLayout

U07-Q022
The container has a row of components that should all be displayed at the same size, filling
the containers entire area. Which layout is the best choice for this purpose?
GridLayout
CardLayout
FlowLayout
BorderLayout
U07-Q023
A component that displays an icon, but that doesnt react to user clicks
label
button
textfield
listbox
combobox
U07-Q028
In JTree control, which of the following classes represents for one node?
DefaultMutableTreeNode
DefaultTreeNode
DefaultMutableNode
MutableTreeNode
U07-Q029
Which of the following layout managers will make all its components the same size?
GridLayout
CardLayout
BorderLayout
GridBagLayout



U07-Q030
You are required to build a GUI application. The application has a main window which
displays:
- A tool bar at the top
- A status bar at the bottom
- A menu on the left
- An information table on the right
- A news board at the middle of the window
Which of the following layout managers would you choose to achieve the above tasks?
BorderLayout
CardLayout
GridLayout
FlowLayout
U07-Q031
Suppose that the layout of the frame f is BorderLayout. Study the following statement:
g.getContentPane().add ( new JButton(B));
The button B will be let at the !. region of the frame.
None of the others.
East
West
North
South
U07-Q032
Suppose you are building an application that connects to the database to store and retreive
data. Your application is built based on Model-View-Controller pattern.
Which of the following components is responsible for connecting to the database?
Model.
View.
Controller.
None of the others.




U07-Q033
Which of the following options is a method that you need to override when implementing the
ActionListener interface?
actionPerformed()
action()
performAction()
perform()
U07-Q034
You are building a table model class that extends the AbstractTableModel class. Which of the
following methods is not required to re-implement?
getColumnName()
getRowCount()
getColumnCount()
getValueAt()
U07-Q035
Which of the following statements is not correct about JTree control?
Leaf nodes are those that can have children.
Every tree has a root node from which all nodes descend.
Branch nodes are those that can have children.
U07-Q036
Which method do you use to force the prompt to a textfield ?
Textfield.requestFocus()
textfield.setEnable(true)
textfield.setActive(true)
textfield.activate()
None of the others.




U07-Q037
A swing container that groups some common components in a complex GUI.
JPanel
JFrame
JTable
JSliptPane
U07-Q038
To make the background color of a label different with the color of its container, we need to
use the !.. method of the JLabel class first.
setOpaque(true)
setBackground(color)
setFloating(!)
setDifferent(!)
U07-Q039
The default layout manager used by JPanel is:
FlowLayout
BorderLayout
GridLayout
None of the others
U07-Q040
Which of the following layout classes is in java.awt package?
All of the others.
Flow Layout
Grid Layout
Border Layout




U07-Q041
Which of the following layout managers arranges components in horizontal rows (left to right
in the order they were added to their container), starting new rows if necessary?
Flow Layout
Grid Layout
Border Layout
Gridbag Layout
U07-Q042
Which of the following layout managers subdivides its territory into a matrix of rows and
columns?
Grid Layout
Flow Layout
Border Layout
Gridbag Layout

U08 - Q024
RMI applications often comprise two separate programs, a server and a client and they...
Can run in two separate virtual machines
Must run in two separate computers
Must run in the same virtual machine
U08 - Q025
In RMI implementations, all methods, declared in the remote interface, must throw the
...exception.
java.rmi.RemoteException
java.lang.Exception
java.rmi.NetworkException
java.rmi.RmiException
None of the others.


U08 - Q026
With respect to the Java socket.
(1) A socket contains two binary streams for sending and receiving data.
(2) A socket contains two text streams for sending and receiving data.
(3) Developers must implement background operations for sending and receiving data.
The statement (1) is ..., (2) is ..., and (3) is ...
True, false, false
True, false, true
False, true, true
False, true, false
None of the others.
U08 - Q027
In a client-server application model, which sides will initiate a connection?
Client
Server
None of them but a middle object
Operation Systems in which they are running
U08-Q001
With respect to networking and the client-server model.
(1) A server runs on a specific computer and has a socket that is bound to a specific port
number. The server just waits, listening to the socket for a client to make a connection
request.
(2) To connect to the server, the client must know the hostname or IP of the machine on
which the server is running and the port number on which the server is listening .
True, true.
True, false
False, true
False, false





U08-Q002
With respect to networking and the client-server model.
(1) A socket is one endpoint (a combination of an IP address and a port number) of a two-way
communication link between two programs running on the network..
(2) TCP (Transmission Control Protocol) is a connection-based protocol that provides a
reliable flow of data between two computers.
(3) UDP (User Datagram Protocol) is a protocol that sends independent packets of data,
called datagrams, from one computer to another with no guarantees about arrival.
True, true, true
True, false, true
True, true, false
False, true, true
None of the others
U08-Q003
With respect to steps in RMI implementation.
(1) Create the remote interface
(2) Create the remote object
(3) Create the client object
(4) Create the Stub
The order should be followed:
1, 2, 4, 3
1, 3, 4, 2
2, 4, 1, 3
2, 3, 1, 4
None of the others
U08-Q004
In Windows systems, the !! program helps creating the Stub of a RMI server and the !!
program will work as a RMI container (RMI registry).
rmic.exe, rmiregistry.exe
rmiregistry.exe, rmic.exe
Stub.exe, rmicontainer.exe
Makestub.exe, rmic.exe
None of the others



U08-Q006
Select incorrect statement about Socket class. (choose 1)
The java.net.Socket class contains code that knows how to find and
communicate with a server through UDP.
One of its constructors is: public Socket(String servername, int portNumber)
You do not directly read from or write to a socket.
The java.net.Socket class contains code that knows how to find and
communicate with a server through TCP.
U08-Q007
Select incorrect statement about ServerSocket class. (choose 1)
The most useful form of the ServerSocket constructor is public ServerSocket(int
portNumber)
A server socket, on the other hand, makes itself available and then waits for
clients to initiate connections.
To make the new object available for client connections, call its accept() method,
which returns an instance of ServerSocket
There is no way to know how long the accept() call will take.
U08-Q008
Select correct statement about RMI. (choose 1)
allow programmers to develop distributed Java programs with the same syntax
and semantics used for non-distributed programs.
use object serialization to marshal and unmarshal parameters, supporting true
object-oriented polymorphism.
RMI applications are often comprised of two separate programs: a server and a
client.
All of the others.
U08-Q009
Select correct statements about remote interface. (choose 1)
A remote interface is an interface that describes the remotely accessible methods
of a remote object.
All remote interfaces must extend java.rmi.Remote.
All methods in a remote interface must throw java.rmi.RemoteException
The type of a remote reference is a remote interface
All of the others.
U08-Q012
Two streams are packed in a socket are .........
InputStream and OutputStream
BufferedReader and PrintWriter
BinaryInputStream and BinaryOutputStream
None of the others.
U08-Q013
To implement RMI, classes need to be implemented:
(1) Remote interface, (2) Server object, (3) Server program, (4) Client program,
(5) Stub object, (6) Transport Object, (7) Remote reference Object
1, 2, 3, 4, 5
1, 2, 3, 4, 6
1, 2, 3, 4, 7
All of them.
U08-Q014
Which of the following statement is correct about object serialization?
Transient fields are not serialized.
All non-transient, including static fields, are serialized.
Class definitions and its objects data are serialized.
None of the others.
U08-Q015
What is the role of RMI registry?
The RMI registry is a program that associates names with RMI services.
The RMI registry is a program that stores stub objects.
The RMI registry is a server program that stores client information.
The RMI registry is a server program that stores both client and server
information.
U08-Q019
RMI applications often comprise two separate programs, a server and a client and they
_________.
can run in two separate virtual machines
must run in two separate computers
must run in the same virtual machine
must run in the same computer
None of the others.
U08-Q020
In RMI implementations, all methods, declared in the remote interface, must throw the ____
exception.
java.rmi.RemoteException
java.rmi.NetworkException
java.rmi.Exception
java.rmi.RmiException
None of the others.

U08-Q021
Select correct statement. In RMI implementations, _____
The remote class must implement the remote inteface.
The client-program class must implement the remote inteface.
The server-program class must implement the remote inteface.
None of the others.
U08-Q022
In Java Network programming using sockets, five steps are usually used:
1) Open a socket.
2) Open an input stream and output stream to the socket.
3) Read from and write to the stream according to the server's protocol.
4) Close the streams.
5) Close the socket.
The right order is:
1, 2, 3, 4, 5
1, 3, 2, 4, 5
1, 2, 5, 3, 4
2, 1, 3, 4, 5
None of the others.
U08-Q023
In a client-server application model, which side will wait for a connection?
server
client
All of sides
None of sides
U08-Q028
Suppose you are building a client server based application using TCP socket technique.
Assume at the same time, 5 clients are connecting to the server, and then the server needs to
send data to the client number 2. How can the server make sure that it sends the data exactly
to the 2
nd
client, rather than mistakenly to other clients?
The server creates a separate InputStream and OutputStream objects for each
one. Then, the server uses these two objects to send and receive data to and from
the specific client.
The server duplicates itself into different instances corresponding to each client.
Each client now has a separate server instance.
The server creates a separate IP address for each one. Then, the server uses
these IP addresses to send and receive data to and from the specific client.
The server creates a separate port address for each one. Then, the server uses
these ports to send and receive data to and from the specific client.


U08-Q029
Which of the following statements is correct?
Basically, RMI technology uses traditional sockets but socket classes are created
invisibly to developers.
TCP is a unreliable transmission protocol because it does not guarantee the data
will be delivered correctly to the destination.
In a computer, IP address is used to identify uniquely a process.
None of the others
U08-Q030
Which of the following protocols is a reliable protocol?
TCP
UDP
TCP and UDP
None of the others
U08-Q031
Two streams in a Java socket are !.
Binary streams
Text streams
Object streams
Primitive streams
U08-Q032
A(An) ...!. is one endpoint of a two-way communication link between two programs running
on the network.
socket
IP
port
NIC
U08-Q033
In RMI Architecture, which of the following components is reponsible for storing a mapping
between a specific name and a remote object?
RMI registry
Stub
Skeleton
Server container
U08-Q034
You are building an rmi application. Which of the following interfaces you must extend for
your remote interface?
java.rmi.Remote
java.rmi.RemoteInterface
java.rmi.RemoteRMI
java.rmi.RMI



U08-Q035
Which of the following options is a valid method that is used to bind a name to an object in
RMI model?
Naming.rebind(name, object);
Naming.bindObject(name, object);
Naming.bindRemoteObject(name, object);
Naming.bindName(name, object);
U08-Q036
With respect to the Java RMI, a server and a client program !!.
can run in two separate virtual machines.
must run in two separate computers.
must run in the same virtual machine.
must run in the same computer.
U08-Q037
Select correct statement. In RMI implementations,
the remote class must implement the remote inteface.
the client-program class must implement the remote inteface.
the server-program class must implement the remote inteface.
None of the others.
U08-Q038
In a client-server application model, which side will initialize a connection?
Client
Server
All of them





U08-Q039
Consider the following url address:
http://192.168.2.2:12/users/index.html
Select a correct statement:
http is protocol, 192.168.2.2:12 is socket.
http is protocol, 192.168.2.2:12/users/index.html is socket
http is protocol, 12 is the socket, and 192.168.2.2:12/users/index.html is IP
address
U08-Q040
You are trying to look up obj1 object on the server 192.168.12.1 using RMI technology with
default port.
Select a correct statement below:
Naming.lookup("rmi://192.168.12.1/obj1") ;
Naming.lookup("find://192.168.12.1:1099/") ;
Naming.lookup("lookup://192.168.12.1:1099/obj1") ;
Naming.lookup("rmi://192.168.12.1:1098/obj1") ;
U08-Q041
Select a correct statement about TCP and UDP protocol:
TCP (Transmission Control Protocol) is a connection-based protocol that
provides a reliable flow of data between two computers.
UDP (Transmission Control Protocol) is a connection-based protocol that
provides a reliable flow of data between two computers.
UDP is connection-based like TCP.
Instead of using TCP, we can use UDP for the same features and benefits.
U08-Q042
A/An !! is bound to a port number so that the TCP layer can identify the application having
network comunication
socket
IP
http address
OSI model



U09 - Q024
With respect to processing models for database access, in the ... model, a Java application
talks directly to the data source.
Two-tier
Three-tier
Multi-tier
None of the other choices.
U09 - Q025
The ... object contains not just an SQL statement, but an SQL statement that has been
precompiled.
PreparedStatement
Statement
ResultSet
Connection
ResultSetMetaData
None of the others.
U09 - Q026
The default type of the ResultSet object is ...
TYPE_FORWARD_ONLY
TYPE_SCROLL_SENSITIVE
TYPE_SCROLL_INSENSITIVE
TYPE_NORMAL
None of the others






U09-Q001
With respect to JDBC,
(1) In the two-tier model, a Java application talks directly to the data source.
(2) In the three-tier model, a "middle tier" of services is let between a Java program and the
data source.
(3) The JDBC API supports two-tier processing model for database access only.
True, true, false
True, true, true
True, false, false
False, true, true
None of the others.
U09-Q002
The correct order in which database -accessing objects should be created:
Connection Statement- ResultSet ResultSetMetaData
Connection ResultSet- Statement - ResultSetMetaData
Connection Statement- ResultSetMetaData- ResultSet
Statement Connection ResultSet ResultSetMetaData
None of the others
U09-Q003
With respect to the java.sql.Statement interface,
(1) When we need retrieving data from a table of a database, the method!! of the
Statement interface should be used.
(2) When we need update data in a table of a database, the method!! of the Statement
interface should be used.
executeQuery(!), executeUpdate(!)
executeUpdate(!), executeQuery(!)
update(), query(!)
query(!), update(!)
None of the others




U09-Q006
Which JDBC processing model that requires a JDBC driver that can communicate with the
particular data source being accessed?
two-tier
three-tier
one-tier
four-tier
U09-Q007
______________ drivers that implement the JDBC API as a mapping to another data access
API, such as ODBC. Drivers of this type are generally dependent on a native library, which
limits their portability.
Type 1
Type 2
Type 3
Type 4
U09-Q008
Statement objects return SQL query results as ___ objects.
DataSet
ResultSet
RecordSet
RowSet
U09-Q012
The Java program can .........
not directly access data in a database file that is managed by a database
management system.
directly read a record in a database file that is managed by a database
management system.
directly read a table in a database file that is managed by a database
management system.
read metadata of a database that is managed by a database management
system.


U09-Q013
The first in the most common objects are used in a database Java program:
(1) java.sql.Connection
(2) java.sql.Statement
(3) java.sql.ResultSet
(4) java.sql.ResultSetMetaData
(1)
(2)
(3)
(4)
One of them.
U09-Q014
Which of the following statements is correct regarding Type 4 JDBC driver (Native Protocol)?
It helps the Java applications communicate directly with the database using Java
sockets.
It helps the Java applications communicate directly with the database through a
third party middleware.
It helps the Java applications communicate directly with the database by calling
C/C++ native libraries.
It helps the Java applications communicate directly with the database by calling
ODBC API.
U09-Q015
Suppose that the current position of a ResultSet, named rs, is at the last record, the
statement rs.next() will return !!
false
true
null reference.
blank record.
U09-Q019
With respect to processing models for database access, ____
In the two-tier model, a Java application talks directly to the data source.
In the three-tier model, a Java application talks directly to the data source.
In the multi-tier model, a Java application talks directly to the data source.
None of the others.
U09-Q020
The JDBC API supports processing models for database access.
two-tier model
three-tier model
two-tier and three-tier models
None of the other choices
U09-Q021
The _____ object contains not just an SQL statement, but an SQL statement that has been
precompiled.
PreparedStatement
Statement
CallableStatement
Connection
U09-Q022
If you want execute a SQL statement many times, the ____ object should be used.
PreparedStatement
Statement
CallableStatement
Connection
U09-Q023
The default type of the ResultSet object is ____.
TYPE_FORWARD_ONLY
TYPE_SCROLL_INSENSITIVE
TYPE_SCROLL_SENSITIVE
None of the others.




U09-Q028
You are required to build an application that can connect to database to display data to end
users. The requirement for the database connectivity is that it must provide a performance as
fast as possible.
Suppose that all types of drivers are available. Which type should you choose to satisfy the
requirement?
Type 2
Type 1
Type 3
Type 4
U09-Q029
One of the benefits of Type 1 driver (JDBC ODBC Bridge) is that it can provide connection
to a database when Java driver is not available for that database. Which of the following
options is another advantage of the Type 1 driver?
None of the others
Platform independence
Faster performance than other driver types
Does not require ODBC driver to be on the server
U09-Q030
Suppose that you will insert a lot of rows into a database table row-by-row. Which of the
following interfaces should be used?
PreparedStatement
Statement
CallableStatement
Connection







U09-Q031
In a JDBC application, suppose that the Connection, named con, was created. Study the
following code:
String sql= select * from Students;
Statement stmt = con.createStatement();
ResultSet rs= stmt.executeQuery(sql);
// code for data accessing in the result set.
con.close();
rs.close();
The above code will throw an exception.
The above code will execute perfectly.
The above code will cause a compile-time error.
None of the others
U09-Q032
In JDBC model, which driver types provide access to database through native code libraries
C/C++?
Type 2-driver
Type 1-driver
Type 3-driver
Type 4-driver
U09-Q033
You are required to build an application that connects to database to store and retrieve data.
Your application must be independent with the underlying database. Which driver types
should you use?
Type 3-driver
Type 2-driver
Type 4-driver
U09-Q034
You are going to execute an insert statement to add some data into the database. Which of
the following methods should you use?
executeUpdate()
executeInsert()
executeQuery()
executeNoneQuery()


U09-Q035
In JDBC, which of the following class/interface should be used to call a store procedure?
CallableStatement
Statement
PreparedStatement
U09-Q036
The !. method of the !! class helps loading a JDBC driver.
forName(!), java.lang.Class
forName(!), java.sql. Connection
load(!), java.lang.Class
loadDriver(!), java.sql.DriverManager



U09-Q037
The next() method of the java.sql.ResultSet class return !!
a boolean value.
an integral value.
a set of records achieved from a database.
Nothing.
U09-Q038
When you want to delete some rows in a table of a database, the !! method of the
java.sql.Statement interface must be used.
executeUpdate()
executeQuery()
modify()
delete()

U09-Q039
In JDBC API, which of the following statements can be used to call a stored procedure?
CallableStatement
PreparedStatement
Statement
U09-Q040
Which of the following is NOT a benefit of using JDBC?
JDBC programs are tightly integrated with the server operating system.
JDBC programs are largely independent of the database to which they are
connected.
Systems built with JDBC are relatively easy to move to different platforms.
JDBC programs can be written to connect with a wide variety of databases.
U09-Q041
In which layer of the JDBC architecture does the JDBC-ODBC bridge reside?
It resides in the JDBC layer.
It resides in both the client program and database layers.
It resides in the database layer.
It resides in the client program layer.

Vous aimerez peut-être aussi