1/997
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
c
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 or more:
a. A Locale is an identifier for a particular combination of language and region
b. To create a properties file, it must use Netbeans or a Java editor
c. Extensions of the properties file must be ".properties"
b
Internationalized software should be developed such that it can be adapted without engineering changes
Select one:
a. FALSE
b. TRUE
c
Which type of driver can use a bridging technology that provides JDBC access via ODBC drivers
Select one:
a. Type-4
b. Type-2
c. Type-1
d. Type-3
b
RMI does not allow you to serialize and transmit objects
Select one:
a. TRUE
b. FALSE
b
Which distributed object technology is most appropriate for systems that consist entirely of Java objects?
Select one:
a. CORBA
b. RMI
c. DOM
d. DCE
b
When using URL class, which method is used to make a connection with that URL?
Select one:
a. makeConnection()
b. openConnection()
c. connect()
d. accept()
c
When a connection is established, we can get which streams
Select one:
a. input stream
b. output stream
c. both input stream and output stream
d. in-out stream
b
A server must retrieve the InputStream and OutputStream from the proxy socket object to communicate with the client
Select one:
a. FALSE
b. TRUE
c
The _______ method wakes up all threads that are waiting for a monitor
Select one:
a. notify()
b. join()
c. notifyAll()
d. wait()
a
Which RMI layer make invocation to remote methods
Select one:
a. Remote Reference layer
b. Transport layer
c. Stub and Skeleton layer
a
______ facilitates many parts of same program to run serially but access a same resource
Select one:
a. Multithread
b. DaemonThread
c. Threading
d. MonoThread
b
You are trying to retrieve the InputStream of the socket. Which of the options will help you to achieved this?
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 or more:
a. The accept() method, once invoked, server will wait till a client requests for a connection Incorrect
b. The accept() method is a blocking method
c. When a client requests, the accept() method creates an object of class ServerSocket and returns it
b
The ServerSocket class has a method clientAccept() for listening to client request?
Select one:
a. TRUE
b. FALSE
c
Which method is used to to retrieve the row IP address in textual format
Select one:
a. getFile()
b. getLocalHost()
c. getHostAddress()
d. getHost()
c
The _____ method forces the current running thread to wait until the thread it is joining with is no longer alive
Select one:
a. interrupt()
b. wait()
c. join()
d. sleep()
b
TCP is a connection-based protocol that provide a reliable flow of data between two computers
Select one:
a. FALSE
b. TRUE
a
Java provides the java.net package which contains all the necessary classes to perform system-dependent network communications
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)
Select one or more:
a. The resource can be an HTML page, an image or simply any file
b. In URL, port number to which you connect has to be specified
c. URL is a reference or an address to a resource on the Internet
d. The format of the resource name depends on the protocol being used
b
Reserved ports ranges from 0 to 1023
Select one:
a. FALSE
b. TRUE
a
A JDialog is a top-level container
Select one:
a. TRUE
b. FALSE
b
How many items can be selected from a JComboBox object at a time?
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. ActionEvent and ItemEvent
B. ItemEvent and ComponentEvent
C. ComponentEvent and ContainerEvent
D. ActionEvent and ContainerEvent
a
The coordinate of the upper-left corner of a frame is __________.
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. private void paintComponent(Graphics g)
B. protected void paintComponent(Graphics g)
C. public void paintComponent(Graphics g)
D. protected void paintComponent()
c
You should override the __________ method to draw things on a Swing component.
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.*;
public class Test {
public static void main(String[] args) {
JFrame frame = new JFrame("My Frame");
frame.add(new MyDrawing("Welcome to Java!"));
frame.setSize(300, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.setVisible(true);
}
}
class MyDrawing extends JPanel {
String message;
public MyDrawing(String message) {
this.message = message;
}
public void paintcomponent(Graphics g) {
super.paintComponent(g);
g.drawString(message, 20 ,20);
}
}
A. The program runs fine and displays Welcome to Java!
B. The program has a compile error because the paintcomponent should be spelled as paintComponent.
C. The program has a runtime error because the paintcomponent should be spelled as paintComponent.
D. The program runs, but it does not display the message.
E. It is a runtime error to invoke the setVisible(true) twice.
c
import java.awt.*;
import javax.swing.*;
public class Test extends JFrame {
public Test() {
add(new MyDrawing("Welcome to Java!"));
}
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setSize(300, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
class MyDrawing extends JPanel {
String message;
public MyDrawing(String message) {
this.message = message;
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawString(message, 20 ,20);
}
}
A. The program runs fine and displays Welcome to Java!
B. The program would display Welcome to Java! if new JFrame() is replaced by Test().
C. The program would display Welcome to Java! if new JFrame() is replaced by new Test().
D. The program would display Welcome to Java! if new JFrame() is replaced by new Test("My Frame").
d
Analyze the following code.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Test1 extends JFrame {
public Test1() {
add(new MyCanvas());
}
public static void main(String[] args) {
JFrame frame = new Test1();
frame.setSize(300, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
class MyCanvas extends JPanel {
private String message;
public void setMessage(String message) {
this.message = message;
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawString(message, 20, 20);
}
}
A. The program runs fine and displays nothing since you have not set a string value.
B. The program would display Welcome to Java! if you replace new MyCanvas() by new MyCanvas("Welcome to Java!").
C. The program has a compile error because new Test1() is assigned to frame.
D. The program has a NullPointerException since message is null when g.drawString(message, 20, 20) is executed.
b
Given a Graphics object g, to draw a line from the upper left corner to the bottom right corner, you use __________.
A. g.drawLine(0, 0, 100, 100)
B. g.drawLine(0, 0, getWidth(), getHeight())
C. g.drawLine(0, 0, getHeight(), getHeight())
D. g.drawLine(0, 0, getWidth(), getWidth())
c
Given a Graphics object g, to draw an outline of a rectangle of width 20 and height 50 with the upper-left corner at (20, 20), you use __________.
A. g.drawRect(20, 50, 20, 20)
B. g.drawRectFill(20, 20, 20, 50)
C. g.drawRect(20, 20, 20, 50)
D. g.drawRectFill(20, 50, 20, 20)
d
Given a Graphics object g, to draw an circle with radius 20 centered at (50, 50), you use __________.
A. g.drawOval(50, 50, 20, 20)
B. g.drawOval(50, 50, 40, 40)
C. g.drawOval(30, 30, 20, 20)
D. g.drawOval(30, 30, 40, 40)
e
Given a Graphics object g, to draw a filled oval with width 20 and height 30 centered at (50, 50), you use __________.
A. g.fillOval(50, 50, 20, 30)
B. g.fillOval(50, 50, 40, 30)
C. g.fillOval(30, 30, 20, 30)
D. g.fillOval(30, 30, 40, 30)
E. g.fillOval(40, 35, 20, 30)
a
To repaint graphics, invoke __________ on a Swing component.
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.*;
public class Test {
public static void main(String[] args) {
Component c = new JButton("OK");
JFrame frame = new JFrame("My Frame");
frame.add(c);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
A. You cannot assign a JButton to a variable of java.awt.Component.
B. You can only add c to a container because c's type is Component.
C. You cannot add a Swing component directly to a JFrame using add(c) prior to JDK 1.4, but it is OK in JDK 1.5.
D. You cannot create a JFrame using new JFrame("My Frame").
c
The correct order of the following three statements is ___________.
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.*;
public class Test {
public static void main(String[] args) {
JFrame frame = new JFrame("My Frame");
frame.add(new JButton("OK"));
frame.add(new JButton("Cancel"));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200, 200);
frame.setVisible(true);
}
}
A. Only button OK is displayed.
B. Only button Cancel is displayed.
C. Both button OK and button Cancel are displayed and button OK is displayed on the left side of button OK.
D. Both button OK and button Cancel are displayed and button OK is displayed on the right side of button OK.
a
How many frames are displayed?
import javax.swing.*;
public class Test {
public static void main(String[] args) {
JFrame f1 = new JFrame("My Frame");
JFrame f2 = f1;
JFrame f3 = f2;
f1.setVisible(true);
f2.setVisible(true);
f3.setVisible(true);
}
}
A. 1.
B. 2.
C. 3.
c
How many frames are displayed?
import javax.swing.*;
public class Test extends JFrame {
public static void main(String[] args) {
JFrame f1 = new Test();
JFrame f2 = new Test();
JFrame f3 = new Test();
f1.setVisible(true);
f2.setVisible(true);
f3.setVisible(true);
}
}
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?
A. A container is another name for an array or vector.
B. A container is any class that is made up of other classes.
C. A container is a primitive variable that contains the actual data.
D. A container is an object like a frame that has other GUI components placed inside of it.
B
Fill in the blanks so that this program displays a JFrame:>
import java.awt.*;
import javax.swint.*;
public class microGUI
{
public static void main ( String[] args )
{
JFrame frm = new ___________();
frm.___________( 150, 100 );
frm.___________( true );
}
}
A. Form, setVisible, setOn
B. JFrame, setSize, setVisible
C. Frame, setVisible, setSize
D. Window, setSize, paint
A
Which of the following sets the frame to 300 pixels wide by 200 high?
A. frm.setSize( 300, 200 );
B. frm.setSize( 200, 300 );
C. frm.paint( 300, 200 );
D. frm.setVisible( 300, 200 );
A
What is it called when a program is written to respond to the button clicks, menu selections, and other actions of the user in whatever order the user does them?
a. Event-driven programming.
b. Action-driven programming.
c. User-driven programming.
d. Mouse-driven programming
B
Usually GUI programs are written by using existing software components provided in a toolkit. The Java toolkit used in this chapter is the:
a. GUI toolkit
b. Abstract Windowing Toolkit
c. Graphics Event Toolkit
d. Java Enhancement Toolkit
C
The three software parts of a GUI program are:
a. Windows, Buttons, Mice
b. GUI Components, Graphics, Code
c. GUI Components, Event Listeners, Application Code
d. Frames, Code, Events