Thẻ ghi nhớ: PRJ301 FPT University

0.0(0)
Studied by 6 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/997

flashcard set

Earn XP

Description and Tags

Last updated 12:48 PM on 7/24/24
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

998 Terms

1
New cards

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()

2
New cards

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

3
New cards

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

4
New cards

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

5
New cards

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"

6
New cards

b

Internationalized software should be developed such that it can be adapted without engineering changes
Select one:
a. FALSE
b. TRUE

7
New cards

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

8
New cards

b

RMI does not allow you to serialize and transmit objects
Select one:
a. TRUE
b. FALSE

9
New cards

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

10
New cards

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()

11
New cards

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

12
New cards

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

13
New cards

c

The _______ method wakes up all threads that are waiting for a monitor
Select one:
a. notify()
b. join()
c. notifyAll()
d. wait()

14
New cards

a

Which RMI layer make invocation to remote methods
Select one:
a. Remote Reference layer
b. Transport layer
c. Stub and Skeleton layer

15
New cards

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

16
New cards

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();
}

17
New cards

b

To create ServerSocket object, it should know the address or port of the client to communicate
Select one:
a. TRUE
b. FALSE

18
New cards

b

A remote object is an instance of the class that implements the java.rmi.Remote interface
Select one:
a. FALSE
b. TRUE

19
New cards

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

20
New cards

b

Remote object and remote server are the same concept
Select one:
a. TRUE
b. FALSE

21
New cards

c

_____ is used to transmit and receive data
Select one:
a. Transport layer
b. Remote Reference layer
c. Stub and Skeleton layer

22
New cards

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

23
New cards

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

24
New cards

c

Which protocol is used in RMI connection
Select one:
a. rmip
b. ftp
c. rmic
d. http

25
New cards

a

The isAlive() method sends a query to inquire, whether the thread is block or not
Select one:
a. FALSE
b. TRUE

26
New cards

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()

27
New cards

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

28
New cards

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

29
New cards

b

The ServerSocket class has a method clientAccept() for listening to client request?
Select one:
a. TRUE
b. FALSE

30
New cards

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()

31
New cards

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()

32
New cards

b

TCP is a connection-based protocol that provide a reliable flow of data between two computers
Select one:
a. FALSE
b. TRUE

33
New cards

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

34
New cards

b

The JFileChooser by default displays all the files in the current directory
Select one:
a. FALSE
b. TRUE

35
New cards

a

Thread priorities are numbers and range from Thread.NORM_PRIORITY to Thread.MAX_PRIORITY
Select one:
a. FALSE
b. TRUE

36
New cards

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()

37
New cards

c

The ______ method returns true if the thread is a user thread
Select one:
a. verifyDaemon()
b. setDaemon()
c. isDaemon()
d. getDaemon()

38
New cards

a

The getPriority() and setPriority() methods retrieve and set the current priority of any thread respectively
Select one:
a. TRUE
b. FALSE

39
New cards

a

The deadlock situation allows the normal execution of the program after few minutes
Select one:
a. FALSE
b. TRUE

40
New cards

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

41
New cards

a

The JList has a method addListSelectionListener() to register a selection listener
Select one:
a. TRUE
b. FALSE

42
New cards

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()

43
New cards

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

44
New cards

b

The lock in synchronized block is based on the method and on the object
Select one:
a. FALSE
b. TRUE

45
New cards

a

A menu system provides a bar above the window's title bar called as menu bar
Select one:
a. FALSE
b. TRUE

46
New cards

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

47
New cards

b

Reserved ports ranges from 0 to 1023
Select one:
a. FALSE
b. TRUE

48
New cards

a

A JDialog is a top-level container
Select one:
a. TRUE
b. FALSE

49
New cards

b

How many items can be selected from a JComboBox object at a time?

A. 0
B. 1
C. 2
D. Unlimited

50
New cards

b

_______________ returns the selected item on a JComboBox jcbo.

A. jcbo.getSelectedIndex()
B. jcbo.getSelectedItem()
C. jcbo.getSelectedIndices()
D. jcbo.getSelectedItems()

51
New cards

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).

52
New cards

b

Clicking a JComboBox object generates an ItemEvent event,

A. if an item is selected.
B. if a new item is selected.

53
New cards

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

54
New cards

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)

55
New cards

a

Clicking a JList object generates __________ events.

A. ActionEvent and ItemEvent
B. ItemEvent and ComponentEvent
C. ComponentEvent and ContainerEvent
D. ActionEvent and ContainerEvent

56
New cards

a

The coordinate of the upper-left corner of a frame is __________.

A. (0, 0)
B. (25, 25)
C. (100, 100)
D. (10, 10)

57
New cards

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)

58
New cards

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()

59
New cards

c

You should override the __________ method to draw things on a Swing component.

A. repaint()
B. update()
C. paintComponent()
D. init()

60
New cards

a

You can draw graphics on any GUI components.

A. true
B. false

61
New cards

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

62
New cards

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.

63
New cards

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").

64
New cards

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.

65
New cards

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())

66
New cards

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)

67
New cards

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)

68
New cards

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)

69
New cards

a

To repaint graphics, invoke __________ on a Swing component.

A. repaint()
B. update()
C. paintComponent()
D. init()

70
New cards

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)

71
New cards

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()

72
New cards

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

73
New cards

a

__________ are referred to as heavyweight components.

A. AWT components
B. Swing components
C. GUI components
D. Non-GUI components

74
New cards

d

Which of the following classes is a heavyweight component?

A. JButton
B. JTextField
C. JPanel
D. JFrame

75
New cards

c

Which component cannot be added to a container?

A. JPanel
B. JButton
C. JFrame
D. JComponent

76
New cards

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

77
New cards

b

What is best to describe the relationship between a container and a layout manager?

A. Association
B. Aggregation
C. Composition
D. Inheritance

78
New cards

d

What is best to describe the relationship between JComponent and JButton?

A. Association
B. Aggregation
C. Composition
D. Inheritance

79
New cards

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").

80
New cards

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

81
New cards

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.

82
New cards

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.

83
New cards

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.

84
New cards

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)

85
New cards

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)

86
New cards

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

87
New cards

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

88
New cards

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

89
New cards

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

90
New cards

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

91
New cards

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.

92
New cards

C

What is the name of the Swing class that is used for frames?
A. Window
B. Frame
C. JFrame
D. SwingFrame

93
New cards

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)

94
New cards

D

The size of a frame on the screen is measured in:
A. inches
B. nits
C. dots
D. pixels

95
New cards

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.

96
New cards

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

97
New cards

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 );

98
New cards

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

99
New cards

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

100
New cards

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