当前位置: 技术问答>java相关
3000元学scjd值不值?
来源: 互联网 发布时间:2015-04-05
本文导语: 最近看到有scjd的培训班,3000rmb,就是不知道参加了就能考出吗? 有没有考scjd的盟友呀? my qq:82396638 | SAMPLE QUESTIONS FOR SCJD [Question 1] Describe the relative merits and costs of using a Vector, a ...
最近看到有scjd的培训班,3000rmb,就是不知道参加了就能考出吗?
有没有考scjd的盟友呀?
my qq:82396638
有没有考scjd的盟友呀?
my qq:82396638
|
SAMPLE QUESTIONS FOR SCJD
[Question 1]
Describe the relative merits and costs of using a Vector, a HashMap, or an array for storing data that might need to be searched.
[Answer 1]
Considerations include ease of use, ease of expansion of the data set, speed of access, speed of searching, ability to include duplicated elements, and size.
The array is simple to use, but hard to extend when full. It is very fast access, but provides no searching api at all (you can search it
by hand). The array can carry duplicated data items, and is the smallest container available.
The Vector is fairly simple to use, although harder than the array. The Vector is readily extensible from the API, although the extension is performed in a fairly inefficient way using array copying. It does provide a search API, although this is not very efficient, since it must make a linear search. A Vector is slightly larger than an equivalent array, but takes less space than the HashMap.
The HashMap has a powerful API, and requires that a unique key be provided for each item stored within it. This is a little harder to handle than an array (but not much). The data set of a HashMap is readily extended, and in most situations, extensive array copying is avoided. Access speed to sequential elements is relatively slow since the data are not stored in a sequential way, however, search speed, provided the search is for an exact match with a key rather than by content, is fast. The HashMap cannot contain duplicate keys, any attempt to add duplicates will cause the previous values to be overwritten. The size of a HashMap is larger than equivalent array or Vector containers, since more organizational data are required.
However, for sizable data collections, the overhead is usually a very small percentage.
[Question 2]
Describe how you might implement a mutual exclusion mechanism to protect data from concurrent access by multiple threads.
[Answer 2]
The synchronization mechanism allows mutual exclusion. Each object has a "lock" associated with it. To enter a "synchronized block" (either a synchronized method, or a sychronized(objectReference) { } construct) the lock must be obtained by the thread. If another thread already holds the required lock, then the new thread is made to wait until the lock is obtained. This mechanism can be used to prevent concurrent access to data by two threads. First, the sensitive data must be private member variables in some object. Second, methods in the class that access these variables should be marked as synchronized or alternatively, all regions of methods that access these variables should be enclosed in the construction synchronized(this) {/* data access here */ }.
The variables should be private to prevent improper (unsynchronized)
accesses by other classes, including package members and subclasses.
[Question 3]
Briefly outline a potential benefit of using RMI rather than using the sockets API directly.
[Answer 3]
Potential answers include (but are not limited to):
RMI allows the Object Oriented paradigm to extend over the network,
allowing cleaner designs
RMI allows both state and behavior to be passed over the network
RMI can simplify deployment and maintenance of distributed systems,
since upgraded classes can often be served centrally, rather than having to be copied into place on all clients
RMI hides the wire protocols
[Question 4]
Briefly outline a potential benefit of using sockets API directly rather than using RMI.
[Answer 4]
Potential answers include (but are not limited to):
The sockets API allows direct control of the wire protocols, for example allowing connection to pre-exising servers/services such as SMTP, Telnet, and so on.
A variation of the above: The sockets API may be used to connect to non-Java services.
The sockets API allows minimum data to be sent over the wire, possibly resulting in shorter round trip times and better performance
The sockets API may be used in some limited virtual machines that do not support RMI and serialization (for example, particular configurations and profiles of the Java 2 Micro Edition (J2ME)).
The sockets API might result in smaller programs, which might be significant in some resource limited devices.
[Question 5]
What class (or base class) is used to store the data values that are displayed in a JList?
[Answer 5]
Any one of these: ListModel, AbstractListModel, DefaultListModel
[Question 6]
You are about to create a new class that will have part of its behavior serve as the starting point for a separate thread. Which of the following is/are true?
1. The class must extend Thread
2. The class must implement Runnable
3. Behavior that is to run in a separate thread must be entirely contained in a method public void run()
4. Behavior that is to run in a separate thread must be entirely enclosed in a synchronized block
5. The new class must provide its own thread
[Answer 6]
The only correct answer is 2) The class must implement Runnable.
It is not necessary for the class itself to inherit from Thread (but note that is this is the case, the class will unavoidably implement Runnable, because Thread implements Runnable). While the starting point of a new thread's execution is the public void run() method, the scope of execution by another thread is not limited to that method. Synchronized blocks are not required for thread execution, rather they are used to control the interactions of concurrent threads. Finally, there is no requirement for the class to provide its own thread, indeed it is commonplace to deliberately create
Thread objects and provide them with other Runnable objects to execute.
[Question 7]
Given that remotely accessible methods published by RMI must be declared as throwing java.rmi.RemoteException, explain why the ActionListener interface cannot be used as a remote interface.
[Answer7]
The remote implementation of a actionPerformed method would have to be declared as
public void actionPerformed(ActionEvent ev) throws RemoteException
but the exception is not permitted in an implementation of the actionPerformed method declared in the ActionListener interface, since no exceptions are declared for that method in that interface.
[Question 1]
Describe the relative merits and costs of using a Vector, a HashMap, or an array for storing data that might need to be searched.
[Answer 1]
Considerations include ease of use, ease of expansion of the data set, speed of access, speed of searching, ability to include duplicated elements, and size.
The array is simple to use, but hard to extend when full. It is very fast access, but provides no searching api at all (you can search it
by hand). The array can carry duplicated data items, and is the smallest container available.
The Vector is fairly simple to use, although harder than the array. The Vector is readily extensible from the API, although the extension is performed in a fairly inefficient way using array copying. It does provide a search API, although this is not very efficient, since it must make a linear search. A Vector is slightly larger than an equivalent array, but takes less space than the HashMap.
The HashMap has a powerful API, and requires that a unique key be provided for each item stored within it. This is a little harder to handle than an array (but not much). The data set of a HashMap is readily extended, and in most situations, extensive array copying is avoided. Access speed to sequential elements is relatively slow since the data are not stored in a sequential way, however, search speed, provided the search is for an exact match with a key rather than by content, is fast. The HashMap cannot contain duplicate keys, any attempt to add duplicates will cause the previous values to be overwritten. The size of a HashMap is larger than equivalent array or Vector containers, since more organizational data are required.
However, for sizable data collections, the overhead is usually a very small percentage.
[Question 2]
Describe how you might implement a mutual exclusion mechanism to protect data from concurrent access by multiple threads.
[Answer 2]
The synchronization mechanism allows mutual exclusion. Each object has a "lock" associated with it. To enter a "synchronized block" (either a synchronized method, or a sychronized(objectReference) { } construct) the lock must be obtained by the thread. If another thread already holds the required lock, then the new thread is made to wait until the lock is obtained. This mechanism can be used to prevent concurrent access to data by two threads. First, the sensitive data must be private member variables in some object. Second, methods in the class that access these variables should be marked as synchronized or alternatively, all regions of methods that access these variables should be enclosed in the construction synchronized(this) {/* data access here */ }.
The variables should be private to prevent improper (unsynchronized)
accesses by other classes, including package members and subclasses.
[Question 3]
Briefly outline a potential benefit of using RMI rather than using the sockets API directly.
[Answer 3]
Potential answers include (but are not limited to):
RMI allows the Object Oriented paradigm to extend over the network,
allowing cleaner designs
RMI allows both state and behavior to be passed over the network
RMI can simplify deployment and maintenance of distributed systems,
since upgraded classes can often be served centrally, rather than having to be copied into place on all clients
RMI hides the wire protocols
[Question 4]
Briefly outline a potential benefit of using sockets API directly rather than using RMI.
[Answer 4]
Potential answers include (but are not limited to):
The sockets API allows direct control of the wire protocols, for example allowing connection to pre-exising servers/services such as SMTP, Telnet, and so on.
A variation of the above: The sockets API may be used to connect to non-Java services.
The sockets API allows minimum data to be sent over the wire, possibly resulting in shorter round trip times and better performance
The sockets API may be used in some limited virtual machines that do not support RMI and serialization (for example, particular configurations and profiles of the Java 2 Micro Edition (J2ME)).
The sockets API might result in smaller programs, which might be significant in some resource limited devices.
[Question 5]
What class (or base class) is used to store the data values that are displayed in a JList?
[Answer 5]
Any one of these: ListModel, AbstractListModel, DefaultListModel
[Question 6]
You are about to create a new class that will have part of its behavior serve as the starting point for a separate thread. Which of the following is/are true?
1. The class must extend Thread
2. The class must implement Runnable
3. Behavior that is to run in a separate thread must be entirely contained in a method public void run()
4. Behavior that is to run in a separate thread must be entirely enclosed in a synchronized block
5. The new class must provide its own thread
[Answer 6]
The only correct answer is 2) The class must implement Runnable.
It is not necessary for the class itself to inherit from Thread (but note that is this is the case, the class will unavoidably implement Runnable, because Thread implements Runnable). While the starting point of a new thread's execution is the public void run() method, the scope of execution by another thread is not limited to that method. Synchronized blocks are not required for thread execution, rather they are used to control the interactions of concurrent threads. Finally, there is no requirement for the class to provide its own thread, indeed it is commonplace to deliberately create
Thread objects and provide them with other Runnable objects to execute.
[Question 7]
Given that remotely accessible methods published by RMI must be declared as throwing java.rmi.RemoteException, explain why the ActionListener interface cannot be used as a remote interface.
[Answer7]
The remote implementation of a actionPerformed method would have to be declared as
public void actionPerformed(ActionEvent ev) throws RemoteException
but the exception is not permitted in an implementation of the actionPerformed method declared in the ActionListener interface, since no exceptions are declared for that method in that interface.
|
能力和水平是工作中干出来的,不能靠认证。
绝对不值。
绝对不值。
|
不值,3000银子呢!
其实只要花100元的上网费去网上Download资料,1250元报名考试,还可以剩下1650元,这些钱拿去干什么不好?非要送给那培训的公司!?
其实只要花100元的上网费去网上Download资料,1250元报名考试,还可以剩下1650元,这些钱拿去干什么不好?非要送给那培训的公司!?
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。