Code COMP90015

Quiz by
LatSwizzle
Rate:
Last updated: November 1, 2023
You have not attempted this quiz yet.
First submittedNovember 1, 2023
Times taken4
Average score31.9%
Report this quizReport
4:00
Enter answer here
0
 / 47 guessed
The quiz is paused. You have remaining.
Scoring
You scored / = %
This beats or equals % of test takers also scored 100%
The average score is
Your high score is
Your fastest time is
Keep scrolling down for answers and more stats ...
Hint
Answer
Create registry
Registry registry = LocateRegistry.createRegistry(port);
Get registry
Registry registry = LocateRegistry.getRegistry(host, port);
Bind RMI object to registry
Registry.bind(“name”, object);
Look up remote object on registry
ObjectClass object = (ObjectClass) registry.lookup(“name”);
RMI interface
public interface InterfaceClass extends Remote{
 
void method() throws RemoteException;
 
}end
Implementing interface
class ObjectClass implements InterfaceClass {
 
@ Override
 
public void method() throws RemoteExceptionstartend
 
}end
Handle an error
Try {
 
ObjectClass.method();
 
} catch (RemoteException e){
 
Handle();
 
}end
Open server socket
ServerSocket server;
 
DataOutputStream os;
 
DataInputStream is;
 
server = new ServerSocket(port);
Wait for client request
Socket client = server.accept();
Create IO streams for communication
is = new DataInputStream(client.getInputStream());
 
os = new DataOutputStream(client.getOutputStream());
Perform communication
String line = is.readLine();
Hint
Answer
 
os.writeBytes("message");
Create socket object for client
client = new Socket( server, port);
Close socket
client.close();
 
is.close();
 
os.close();
Handle socket errors
catch(UnknownHostException e){
 
handle();
 
}end
 
catch(IOException e) {
 
handle();
 
}end
Extending thread class (MyThread, runThread())
class MyThread extends Thread{
 
public void run(){
 
runThread();
 
}end
 
}end
Implementing Runnable (MyThread, runThread())
class MyThread implements Runnable{
 
public void run(){
 
runThread();
 
}end
 
}end
Instantiate and start a thread (one line)
new MyThread().start();
Set Priority of a thread
ThreadName.setPriority(priority)
Save Your Stats
Your Next Quiz
Name all 50 states in the USA. Easy, right?
How many of the world's 24 most populous countries can you name?
Can you name the countries with the highest GDP per capita?
Can you name the ten Asian countries with the largest GDPs?
Comments
No comments yet