Professional Documents
Culture Documents
PRJ311
PRJ311
PRJ311
To get an object NumberFormat class that initialized to the specified locale, we use
Select one:
a. getNumberFormat()
b. getCurrencyInstance()
c. getNumberInstance()
d. getInstance()
b
Which type of driver can interpret JDBC calls to the database-specific native call
interface
Select one:
a. Type-1
b. Type-2
c. Type-4
d. Type-3
bc
Which are advantages of JDBC ? (select two)
Select one or more:
a. enable connecting to any database system
b. vendor independent
c. platform independent
d. database access faster than other languages
a
Formatting the captions of the GUI components ensures that the look and feel of the
application is in a locale-sensitive manner
Select one:
a. TRUE
b. FALSE
ac
Which statements are CORRECT about properties file? (Select 2)
Select one:
a. Socket socket;
String host;
BufferedReader reader;
try {
socket = new Socket("localhost", -200);
reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
} catch(Exception ex) {
ex.printStackTrace();
}
b. Socket socket;
String host;
BufferedReader reader;
try {
socket = new Socket("localhost", 200);
reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
} catch(Exception ex) {
ex.printStackTrace();
} Correct
c. Socket socket;
String host;
BufferedReader reader;
try {
socket = new Socket("localhost", 200);
reader = new BufferedReader(new InputStreamReader(socket.getStream()));
} catch(Exception ex) {
ex.printStackTrace();
}
d. Socket socket;
String host;
BufferedReader reader;
try {
socket = new Socket("localhost", 200);
reader = new BufferedReader(new InputStream(socket.getInputStream()));
} catch(Exception ex) {
ex.printStackTrace();
}
b
To create ServerSocket object, it should know the address or port of the client to
communicate
Select one:
a. TRUE
b. FALSE
b
A remote object is an instance of the class that implements the java.rmi.Remote
interface
Select one:
a. FALSE
b. TRUE
d
The _______ condition describes a situation where two or more threads a blocked
forever, waiting for each other
Select one:
a. synchronization
b. race
c. blocking
d. deadlock
b
Remote object and remote server are the same concept
Select one:
a. TRUE
b. FALSE
c
_____ is used to transmit and receive data
Select one:
a. Transport layer
b. Remote Reference layer
c. Stub and Skeleton layer
a
All the remote methods declared should be qualified to throw the exception
___________
Select one:
a. java.rmi.RemoteException
b. java.rmi.ServerRuntimeException
c. java.rmi.MarshalException
d. java.rmi.RMIException
a
Which class stores information about an Internet resource address including host name,
file name, port number.
Select one:qualified
a. URL
b. Connection
c. InternetAddr
d. URLConnection
c
Which protocol is used in RMI connection
Select one:
a. rmip
b. ftp
c. rmic
d. http
a
The isAlive() method sends a query to inquire, whether the thread is block or not
Select one:
a. FALSE
b. TRUE
b
The ______ method with the argument as true will convert the user thread to a daemon
thread
Select one:
a. isDaemon()
b. setDaemon()
c. convertToDaemon()
d. SetDaemon()
c
Which package providing classes and interfaces for distributed computing in Java
Select one:
a. java.net
b. javax.rmi
c. java.rmi
d. javax.net
c
Which statements are TRUE about accept() method - select 2?
Select one:
a. TRUE
b. FALSE
b
The JFileChooser by default displays all the files in the current directory
Select one:
a. FALSE
b. TRUE
a
Thread priorities are numbers and range from Thread.NORM_PRIORITY to
Thread.MAX_PRIORITY
Select one:
a. FALSE
b. TRUE
a
The ______ method causes a thread to release the lock or monitor of the object,
allowing another thread to access it
Select one:
a. wait()
b. notifyAll()
c. finalize()
d. notify()
c
The ______ method returns true if the thread is a user thread
Select one:
a. verifyDaemon()
b. setDaemon()
c. isDaemon()
d. getDaemon()
a
The getPriority() and setPriority() methods retrieve and set the current priority of any
thread respectively
Select one:
a. TRUE
b. FALSE
a
The deadlock situation allows the normal execution of the program after few minutes
Select one:
a. FALSE
b. TRUE
b
Using new TextField(10) will create a TextField that only accepts 10 characters of input.
Select one:
a. Depends on the particular implementation of the Java Virtual Machine
b. FALSE
c. TRUE
a
The JList has a method addListSelectionListener() to register a selection listener
Select one:
a. TRUE
b. FALSE
e
Which method do you use to start a Thread?
Select one:
a. init()
b. Depends on the particular implementation of the Java Virtual Machine
c. run()
d. begin()
e. start()
f. departure()
ba
A synchronised block is a _____ or a _____ qualified by synchronized keyword
Select one or more:
a. block of code
b. method
c. class
d. function
b
The lock in synchronized block is based on the method and on the object
Select one:
a. FALSE
b. TRUE
a
A menu system provides a bar above the window's title bar called as menu bar
Select one:
a. FALSE
b. TRUE
acd
Which statements are CORRECT about network resource? (Select 3)
A. 0
B. 1
C. 2
D. Unlimited
b
_______________ returns the selected item on a JComboBox jcbo.
A. jcbo.getSelectedIndex()
B. jcbo.getSelectedItem()
C. jcbo.getSelectedIndices()
D. jcbo.getSelectedItems()
c
The method __________ adds an item s into a JComboBox jcbo.
A. jcbo.add(s)
B. jcbo.addChoice(s)
C. jcbo.addItem(s)
D. jcbo.addObject(s).
b
Clicking a JComboBox object generates an ItemEvent event,
A. if an item is selected.
B. if a new item is selected.
c
____________ is a component that enables the user to choose a single value or
multiple values.
A. A text field
B. A combo box
C. A list
D. A label
c
______________ sets the background of the selected item in list jlst to yellow.
A. jlst.setBackground(Color.YELLOW)
B. jlst.setSelectedBackground(Color.YELLOW)
C. jlst.setSelectionBackground(Color.YELLOW)
D. jlst.setSelectionbackground(Color.YELLOW)
a
Clicking a JList object generates __________ events.
A. (0, 0)
B. (25, 25)
C. (100, 100)
D. (10, 10)
a
Suppose a button jbt is placed in a frame, the coordinate of the button within the content
pane of the frame is _______.
A. (jbt.getX(), jbt.getY())
B. (jbt.x, jbt.y)
C. cannot be obtained
D. (0, 0)
b
The header for the paintComponent method is ________________.
A. repaint()
B. update()
C. paintComponent()
D. init()
a
You can draw graphics on any GUI components.
A. true
B. false
c
To draw graphics, it is better to define a class that extends ________ and override the
paintComponent method.
A. JLabel
B. JButton
C. JPanel
D. JComponent
d
import java.awt.*;
import javax.swing.*;
g.drawString(message, 20 ,20);
}
}
g.drawString(message, 20 ,20);
}
}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
A. repaint()
B. update()
C. paintComponent()
D. init()
c
Invoking __________ returns the width of the string in a FontMetrics object fm.
A. getLength(s)
B. fm.getHeight(s)
C. fm.stringWidth(s)
D. fm.getWidth(s)
b
To create an Image object from an ImageIcon object imageIcon, use the __________
method.
A. imageIcon.image()
B. imageIcon.getImage()
C. imageIcon.setImage()
D. imageIcon.returnImage()
a
Swing components that don't rely on native GUI are referred to as ___________.
A. lightweight components
B. heavyweight components
C. GUI components
D. non-GUI components
a
__________ are referred to as heavyweight components.
A. AWT components
B. Swing components
C. GUI components
D. Non-GUI components
d
Which of the following classes is a heavyweight component?
A. JButton
B. JTextField
C. JPanel
D. JFrame
c
Which component cannot be added to a container?
A. JPanel
B. JButton
C. JFrame
D. JComponent
c
What is best to describe the relationship between a container and a SWing GUI object
in the container?
A. Association
B. Aggregation
C. Composition
D. Inheritance
b
What is best to describe the relationship between a container and a layout manager?
A. Association
B. Aggregation
C. Composition
D. Inheritance
d
What is best to describe the relationship between JComponent and JButton?
A. Association
B. Aggregation
C. Composition
D. Inheritance
c
Analyze the following code.
import java.awt.*;
import javax.swing.*;
1. frame.setLocationRelativeTo(null);
2. frame.setSize(100, 200);
3. frame.setVisible(true);
A. 1 2 3
B. 1 3 2
C. 2 1 3
D. 3 2 1
b
Analyze the following code.
import java.awt.*;
import javax.swing.*;
import javax.swing.*;
import javax.swing.*;
A. 1.
B. 2.
C. 3.
D. 0.
a
Which of the following statements is for terminating the program when closing the
frame?
A. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
B. frame.setDefaultCloseOperation(null)
C. frame.setDefaultCloseOperation(JFrame.STOP_ON_CLOSE)
D. frame.setDefaultCloseOperation(JFrame.TERMINATE_ON_CLOSE)
c
Which of the following statements is for placing the frame's upper left corner to (200,
100)?
A. frame.setLocation(100, 100)
B. frame.setLocation(100, 200)
C. frame.setLocation(200, 100)
D. frame.setLocation(200, 200)
b
What layout manager should you use so that every component occupies the same size
in the container?
A. a FlowLayout
B. a GridLayout
C. a BorderLayout
D. any layout
a
What should you use to position a Button within an application Frame so that the size of
the Button is NOT affected by the Frame size?
A. a FlowLayout
B. a GridLayout
C. the center area of a BorderLayout
D. the East or West area of a BorderLayout
E. the North or South area of a BorderLayout
D
How do you indicate where a component will be positioned using Flowlayout?
a) North, South,East,West
b) Assign a row/column grid reference
c) Pass a X/Y percentage parameter to the add method
d) Do nothing, the FlowLayout will position the component
A
How do you change the current layout manager for a container?
a) Use the setLayout method
b) Once created you cannot change the current layout manager of a component
c) Use the setLayoutManager method
d) Use the updateLayout method
B
When using the GridBagLayout manager, each new component requires a new
instance of the GridBagConstraints class. Is this statement true or false?
a) true
b) false
D
In Java, what do you call an area on the screen that has nice borders and various
buttons along the top border?
A. A window.
B. A screen.
C. A box.
D. A frame.
C
What is the name of the Swing class that is used for frames?
A. Window
B. Frame
C. JFrame
D. SwingFrame
A
What method sets the size of the displayed JFrame?
A. setSize( int width, int height)
B. setSize( int height, int width)
C. setVisible( int width, int height)
D. setVisible( int height, int width)
D
The size of a frame on the screen is measured in:
A. inches
B. nits
C. dots
D. pixels
D
What is a container object in GUI programming?
import java.awt.*;
import javax.swint.*;
import java.io.*;
class serialization {
public static void main(String[] args) {
try {
Myclass object1 = new Myclass("Hello", -7, 2.1e10);
FileOutputStream fos = new FileOutputStream("serial");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(object1);
oos.flush();
oos.close();
}
catch(Exception e) {
System.out.println("Serialization" + e);
System.exit(0);
}
try {
int x;
FileInputStream fis = new FileInputStream("serial");
ObjectInputStream ois = new ObjectInputStream(fis);
x = ois.readInt();
ois.close();
System.out.println(x);
}
catch (Exception e) {
System.out.print("deserialization");
System.exit(0);
}
}
}
class Myclass implements Serializable {
String s;
int i;
double d;
Myclass(String s, int i, double d){
this.d = d;
this.i = i;
this.s = s;
}
}
a) -7
b) Hello
c) 2.1E10
d) deserialization
D
import java.io.*;
class serialization {
public static void main(String[] args) {
try {
Myclass object1 = new Myclass("Hello", -7, 2.1e10);
FileOutputStream fos = new FileOutputStream("serial");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(object1);
oos.flush();
oos.close();
}
catch(Exception e) {
System.out.println("Serialization" + e);
System.exit(0);
}
try {
int x;
FileInputStream fis = new FileInputStream("serial");
ObjectInputStream ois = new ObjectInputStream(fis);
x = ois.readInt();
ois.close();
System.out.println(x);
}
catch (Exception e) {
System.out.print("deserialization");
System.exit(0);
}
}
}
class Myclass implements Serializable {
String s;
int i;
double d;
Myclass(String s, int i, double d){
this.d = d;
this.i = i;
this.s = s;
}
}
a) -7
b) Hello
c) 2.1E10
d) deserialization
D
What is the output of this program?
import java.io.*;
class streams {
public static void main(String[] args) {
try {
FileOutputStream fos = new FileOutputStream("serial");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeFloat(3.5);
oos.flush();
oos.close();
}
catch(Exception e) {
System.out.println("Serialization" + e);
System.exit(0);
}
try {
FileInputStream fis = new FileInputStream("serial");
ObjectInputStream ois = new ObjectInputStream(fis);
ois.close();
System.out.println(ois.available());
}
catch (Exception e) {
System.out.print("deserialization");
System.exit(0);
}
}
}
a) 1
b) 2
c) 3
d) 4
a
When creating a client on a server port that is already in use, __________.
A. the client can connect to the server regardless of whether the port is in use.
B. java.net.BindException occurs.
C. the client is blocked until the port is available.
D. the client encounters a fatal error and must be terminated.
a
The client requests a connection to a server using the following statement:
A. java.net.BindException occurs.
B. java.net.ConnectionException occurs.
C. the client is blocked until the server is started.
D. the client encounters a fatal error and must be terminated.
b
o create an InputStream on a socket s, you use __________.
A. getIP()
B. getIPAddress()
C. getHostAddress()
D. getAddress()
d
A ServerSocket can connect to ________ clients.
A. one
B. two
C. ten
D. an unlimited number of
b
You can obtain the server's hostname by invoking _________ on an applet.
A. getCodeBase().host()
B. getCodeBase().getHost()
C. getCodeBase().hostName()
D. getCodeBase().getHostName()
e
To obtain an ObjectOutputStream from a socket, use ________.
A. socket.getOutputStream()
B. socket.getObjectStream()
C. socket.getObjectOutputStream()
D. socket.objectOutputStream()
E. new ObjectOutputStream(socket.getOutputStream())
a
Clicking a JButton object generates __________ events.
A. ActionEvent
B. ItemEvent
C. ComponentEvent
D. ContainerEvent
a
Pressing the Enter key on a JTextField generates _____________ events.
A. ActionEvent
B. ItemEvent
C. ComponentEvent
D. ContainerEvent
c
The method __________ appends a string s into the text area jta.
A. jta.setText(s)
B. jta.appendText(s)
C. jta.append(s)
D. jta.insertText(s)
b
To wrap a line in a text area jta, invoke ____________.
A. jta.setLineWrap(false)
B. jta.setLineWrap(true)
C. jta.WrapLine()
D. jta.wrapText()
b
To wrap a line in a text area jta on words, invoke ____________.
A. jta.setWrapStyleWord(false)
B. jta.setWrapStyleWord(true)
C. jta.wrapStyleWord()
D. jta.wrapWord()
a
The method __________ adds a text area jta to a scrollpane jScrollPane.
A. jScrollPane.add(jta)
B. jScrollPane.insert(jta)
C. jScrollPane.addItem(jta)
D. None of the above.
d
How many items can be added into a JComboBox object?
A. 0
B. 1
C. 2
D. Unlimited
D
You can invoke ______________ on a Socket object, say socket, to obtain an
InetAddress object.
A. socket.obtainInetAddress();
B. socket.InetAddress();
C. socket.retrieveInetAddress();
D. socket.getInetAddress();
D
To connect to a server running on the same machine with the client, which of the
following can be used for the hostname?
A. InetAddress.getLocalHost(),
B. "127.0.0.1"
C. "localhost"
D. All of the above.
A
The server listens for a connection request from a client using the following statement:
A. Socket s = serverSocket.accept()
B. Socket s = new Socket(ServerName);
C. Socket s = serverSocket.getSocket()
D. Socket s = new Socket(ServerName, port);
B
The server can create a server socket regardless of whether the port is in use or not.
A. true
B. false
A
The client can connect to the server regardless of whether the port is in use or not.
A. true
B. false
B
You cannot get instances of InputStream or OutputStream because InputStream and
OutputStream are abstract classes.
A. true
B. false
B
An applet cannot connect to a server program on a Web server where the applet was
loaded.
A. false
B. true
B
You can transmit objects over the socket.
A. false
B. true
A
The URL constructor throws MalformedURLException if the URL is syntactically
incorrect.
A. true
B. false
B
getInputStream() and getOutputStream() are used to produce InputStream and
OutputStream on the socket.
A. false
B. true
C
Which of the following code is correct to obtain hour from a Calendar object cal?
A. cal.getHour();
B. cal.get(Hour);
C. cal.get(Calendar.HOUR);
D. cal.hour();
A
A resource bundle is ___________
A. a Java class file or a text file that provides locale-specific information.
B. a Java source code the contains image, audio, and text files.
C. an audio file.
D. an image file.
A
To display number in desired format, you have to use the NumberFormat class or its
subclasses.
A. true
B. false
B
You can find all the available locales from a Swing object.
A. true
B. false
A
The locale property is in the Component class, thus, every Java Swing component has
the locale property.
A. true
B. false
A
You can get year, month, day, hour, minute, and second from an instance of
GregorianCalendar.
A. true
B. false
A
You can get hour, minute and second from the Date class.
A. false
B. true
B
The TimeZone class has a static method for obtaining all the available time zone IDs.
A. false
B. true
B
You can get all the available locales from an instance of Calendar, Collator,
DateFormat, or NumberFormat.
A. false
B. true