Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Login

Register Now

Welcome to All Test Answers

Chapter 19 Java Never Ends – absolute java test bank


 

Download  file with the answers

Not a member!
Create a FREE account here to get access and download this file with answers


Chapter 19
Java Never Ends
 Multiple Choice
1) Threads execute in a ___________ fashion.
(a) parallel
(b) serial
(c) complex
(d) none of the above

2) Java’s Thread class is in the ____________ package.
(a) java.util
(b) java.thread
(c) java.lang
(d) javax.swing

3) The sleep method of the Thread class requires one formal parameter that represents the number of:
(a) nanoseconds
(b) microseconds
(c) picoseconds
(d) milliseconds

4) What method in the Thread class is responsible for pausing a thread for a specific amount of milliseconds?
(a) pause()
(b) sleep()
(c) hang()
(d) kill()

5) The programming statements used to accomplish a threads task should be included in the method:
(a) start()
(b) init()
(c) run()
(d) none of the above

6) ____________ refers to a framework that facilitates software building by connecting software components from diverse sources.
(a) JavaBeans
(b) Threads
(c) SQL
(d) all of the above

7) ____________ means that an object has an identity that extends beyond one session.
(a) Event handling
(b) Introspection
(c) Persistence
(d) None of the above

8) ____________ is an enhancement of simple accessor and mutator methods.
(a) Event handling
(b) Introspection
(c) Persistence
(d) None of the above

9) The Java library that supports database connectivity is called:
(a) ODBC
(b) CDBC
(c) MDBC
(d) JDBC

10) When a server executes the accept() method it:
(a) Blocks and waits for a connection
(b) Checks for a connection and if there is none it exits
(c) Blocks but in a new thread
(d) Any of the above, depending on the input parameters to accept()

11) If your class implements Runnable then what method is invoked to start the thread?
(a) run()
(b) execute()
(c) start()
(d) main()

12) What is an advantage of applying Java 8 lambda expressions to a Collection class?
(a) The potential for syntax errors is reduced
(b) The JVM can parallelize operations applied to elements of the collection
(c) The collection can be displayed graphically
(d) Lambda expressions help map the collection to a database

13) The JavaFX scene graph:
(a) Is used to plot XY graphs
(b) Describes the layout of GUI components in a JavaFX application
(c) Is an application that is used to lay out components in a JavaFX application
(d) Is used with lambda expressions to define nameless functions

 True/False
1) The Java language does not support multithreading.

2) An InterruptedException is a checked exception.

3) A thread’s start method invokes the thread’s run method.

4) An alternative to deriving a thread from the Thread class is to inherit the Runnable interface.

5) SQL stands for Structured Query Language.

6) A server creates at least two sockets, one to listen for input, and another that is created when a client connects to the server.

7) The FXML file in a JavaFX application contains the code that controls what happens when GUI components are selected.

• Short Answer/Essay
1) Discuss the components of the JavaBean model.
Answer: The software components (classes) are required to provide at least the following interface service or abilities:
a. Rules to ensure consistency in writing interfaces.
b. An event handling model
c. Persistence
d. Introspection
e. Builder support
2) What is a JavaBean?
Answer: A JavaBean is a reusable software component that satisfies the requirements of the JavaBeans framework and that can be manipulated in an IDE designed for building applications out of Beans.
3) What are Enterprise JavaBeans?
Answer: The Enterprise JavaBean framework extends the JavaBeans framework to more readily accommodate business applications.
4) What other programming technique can be combined with sockets so a server can handle requests from multiple clients?
Answer: Threads

5) What is a socket?
Answer: A socket describes one end of the connection between two programs over the network. A socket consists of an address that identifies the remote computer and a port for both the local and remote computer.

6) Rewrite the following code to use a Lambda expression for the button action listener.

import java.util.ArrayList;
import javax.swing.JButton;
import javax.swing.JFrame;
import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;

public class ButtonDemo3 extends JFrame
{
public ButtonDemo3( )
{
setSize(250, 100);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle(“Button Demo”);
Container contentPane = getContentPane( );
contentPane.setBackground(Color.BLUE);
contentPane.setLayout(new FlowLayout( ));

JButton goButton = new JButton(“Green”);
goButton.addActionListener(
{ e } -> contentPane.setBackground(Color.GREEN));
contentPane.add(goButton);
}

public static void main(String[] args)
{
ButtonDemo3 buttonGui = new ButtonDemo3( );
buttonGui.setVisible(true);
}
}

Answer:

import java.util.ArrayList;
import javax.swing.JButton;
import javax.swing.JFrame;
import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;

public class ButtonDemo3 extends JFrame
{
public ButtonDemo3( )
{
setSize(250, 100);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle(“Button Demo”);
Container contentPane = getContentPane( );
contentPane.setBackground(Color.BLUE);
contentPane.setLayout(new FlowLayout( ));

JButton goButton = new JButton(“Green”);
goButton.addActionListener(
e -> contentPane.setBackground(Color.GREEN));
contentPane.add(goButton);
}

public static void main(String[] args)
{
ButtonDemo3 buttonGui = new ButtonDemo3( );
buttonGui.setVisible(true);
}
}

About

Leave a reply

Captcha Click on image to update the captcha .

error: Content is protected !!