This class is useful for a Client that wants to connect to a TCP/IP service. Out
ID: 3858021 • Letter: T
Question
This class is useful for a Client that wants to connect to a TCP/IP service.
OutputStream
ObjectOutputStream
Connection
Socket
You are storing data objects in a HashSet.
Which methods must be properly implemented in your
data objects (Check all that apply)
cloneable
compareTo (implementing the Comparable interface)
clone
equals
sort
hashCode
Which data structures would be helpful for creating a stack type of data structure
HashMap
TreeSet
HashSet
ArrayList
The output will be:
MI OH
A compile error occurs on the iterator call
(line number 11)
The output will be:
MI=Lansing OH=Columbus
The output will be:
Lansing Columbus
You are storing data objects in a TreeSet.
Which methods should be properly implemented in your
data objects (Check all that apply pick 2).
compareTo (implementing the Comparable interface)
equals
sort
cloneable
clone
hashCode
The System will throw an "Unhandled Mouse Click" exception when it discovers that the MouseListener is never connected.
A compile error will result once Eclipse discovers that it has a class that implements MouseListener, but this class is never passed to the system.
No Compile error or runtime error. However, when our code executes we will not be informed of Mouse clicks.
A runtime exception will occur when we exit the constructor, because the system will detect an unconnected MouseListener
this method needs to be implemented if your class implements the Runnable interface.
run
start
execute
sleep
This Java package deals with Graphical user interfaces. The original approach used platform specific code for drawing objects, but this package provided a more consistent Java approach to implementing components like buttons, drop down boxes, etc.
graphics
awt
swing
java_graphics
This is an interface that is used for classes which are interested in managing the location and sizes of all of the components in a container.
LayoutManager
ComponenentListener
ComponentManager
LayoutListener
this method is defined in the ActionListener interface.
actionEvent
action
event
actionPerformed
The following block of code creates a Thread using a Runnable target:
Runnable target = new MyRunnable();
Thread myThread = new Thread (target);
Which of the following classes can be used to create the target, so that the preceding code compiles correctly?
public class MyRunnable implements Runnable{
public void run() {/* Some Code */}
}
public class MyRunnable extends Object {
public void run() {/* Some Code */}
}
public class MyRunnable implements Thread{
public void run(){/* Some Code */}
}
public class MyRunnable extends Runnable{
public void run(){ /* Some Code */}
}
This class has methods that allow you to create directories, delete files, and rename files.
fileSystem
Directory
File
FileSystem
The program aborts with an exception
A compile error at line 11 will occur because doit needs to surround the throw statement with try-catch logic, or change it's declaration to:
void doit throws MyError1
The program will run and generate the output "Exception"
The program will run and generate the output "MyError1"
The program will run and generate the output "RuntimeException"
This low level abstract class is used for reading a stream of bytes
FileInputStream
Reader
InputStream
ObjectInputStream
This class provides buffering for OutputStreams. This class has a lot of overloaded methods named either print or println.
PrintStream
FileStream
Writer
WriteStream
OutputStream
ObjectOutputStream
Connection
Socket
Explanation / Answer
Question 30
This class is useful for a Client that wants to connect to a TCP/IP service.
ans: Socket
Socket class is used to connect to network using TCP/IP protocol.
this class is found in java.net packages.
other options OutputStream, ObjectOutputStream, Connection are irellavant to TCP/IP
Question 31
You are storing data objects in a HashSet.
Which methods must be properly implemented in your
data objects (Check all that apply)
ans: equals and hashCode
these methods are useful for comapring the object on basic calculated hashCode.
if u dont implement it java will manupulate default hashCode and equals method.
others are utitlity methods and are already implemented
Question 32
Which data structures would be helpful for creating a stack type of data structure.
ans:ArrayList
another options HashSet and HashMap are not applicaple becuase they do not have gurantied insertion order and
also dont allow to insert duplicate element. And TreeSet have naturally sorting which sorts the data.
ArrayList follows the insertion order which is very required in stack and also allow duplicate objects.
Question 33
image boken, question incomplete
Question 34
You are storing data objects in a TreeSet.
Which methods should be properly implemented in your
data objects (Check all that apply pick 2).
ans: equals and hashCode
these methods are useful for comapring the object on basic calculated hashCode.
if u dont implement it java will manupulate default hashCode and equals method.
Question 35
image boken, question incomplete
Question 36
this method needs to be implemented if your class implements the Runnable interface.
ans : run
Runnable interface have only one abstract method run.
when u implement the Runnable so you have to implement this.
other options are irellavant.
Question 37
This Java package deals with Graphical user interfaces. The original approach used platform specific code for drawing objects,
but this package provided a more consistent Java approach to implementing components like buttons, drop down boxes, etc.
ans: swing
swing are built on top of awt and are platform independent.
other options graphics and java_graphics are not valid packages.
Question 38
This is an interface that is used for classes which are interested in managing the location and sizes of all of the components in a container.
ans : LayoutManager
LayoutManager is responsible for managing the location of components.
and class ComponentListener are used for event of components.
other options ComponentManager and LayoutListener are not valid classes/interface in java.
Question 39
this method is defined in the ActionListener interface.
ans : actionPerformed
this is the only method in ActionListener interface
used to track the actions events.
other options are invalid as they not defined in ActionListener.
Question 40
The following block of code creates a Thread using a Runnable target:
Runnable target = new MyRunnable();
Thread myThread = new Thread (target);
Which of the following classes can be used to create the target, so that the preceding code compiles correctly?
ans :
public class MyRunnable implements Runnable{
public void run() {/* Some Code */}
}
MyRunnable class implementing the Runnable interface and also implemented the run method.
others options are valid because:
public class MyRunnable extends Object {
public void run() {/* Some Code */}
}
run() method is only in Runnable interface and Thread class.
public class MyRunnable implements Thread{
public void run(){/* Some Code */}
}
Thread is class and it cannot be implemented it only can extended.
public class MyRunnable extends Runnable{
public void run(){ /* Some Code */}
}
Runnable is an interface and it can be extende by interface only and other class have to implement interface
Question 41
This class has methods that allow you to create directories, delete files, and rename files.
ans : File
File class have different-different methods for creating directories,and mulitple file operations.
other option fileSystem and Directory are not valid class in java.
and FIleSystem is an abstract class used for getting the fileSystem of OS.
Question 42
This method is in the Graphics class and is useful for displaying text on a screen
ans : drawString
drawString is only method in Graphics that used to draw string.
other options text,displayString,drawListener are not valid methods of Graphics
Question 43
image boken, question incomplete
Question 44
This low level abstract class is used for reading a stream of bytes
ans : InputStream
this is super classes who representds all bytes stream as input.
other option Reader is responsible for reading the character stream.
and FIleInputStream and ObjectInputStream are not an abstract class,
Question 45
This class provides buffering for OutputStreams. This class has a lot of overloaded methods named either print or println.
ans : PrintStream
this class have all the printstream classed.
//please do let me know if u have any doubts...