1. Which exception must be caught or declared when calling the sleep method?

2. Name the exception thrown by the write() method defined in OutputStream class?

3. Which method of DatagramPacket is used to find the port number?

4. What is the output of the following code fragment?

int x=0;
{
int x=100;
System.out.print(x+",");
}
System.out.print(x);

5. What is wrong with the following interface:

public interface Car
{
public void aCar(String name)
{
System.out.println("Honda-Jazz ");
}
}

6. What will happen when executing the following fragment of code?

int x=10;
do
{
x--;
}while(x <10);

7. Fill in the blanks in order for the code to create a text field of 20 characters into the frame?

public TextExample() {
text = new JTextField( ____ ) ;
_________( new FlowLayout() );
add( ____ );
}

8. Write Java code that creates a TCP server socket and listens for a connection.

9. Fill in the blanks so that the following program displays a JFrame:

import java.awt.*;
public class microGUI
{
public static void main ( String[] args )
{
JFrame frm = new ___________();
frm.___________( 300, 500 );
frm.___________( true );
}
}

10. What is the output of the following Java program?

import java.net.*;
class networking {
public static void main(String[] args) throws
UnknownHostException {
InetAddress obj1=InetAddress.getByName("cisco.com");
System.out.print(obj1.getHostName());}
}

11. In the java.io package, what is difference between throwing an exception and catching an expectation? What happens if an exception does not have a matching catch clause?

12. Explain the characteristics of symmetric and asymmetric key encryption algorithms, and describe the main weakness of symmetric key algorithms.

13. Briefly explain steps which are executed by a sender, and steps which are executed by a receiver, in order to communicate with each other using TCP sockets. You should write the code/statements to illustrate your answer.

14. Briefly describe the characteristics of Concurrent Systems. List the advantages and disadvantages of concurrency.

15. A client connects a server. The client takes 6 ms to compute the arguments for each request, and the server takes 8 ms to process each request. The local OS processing time for each send or receive operation is 0.5 ms, and the network time to transmit each request or reply message is 4 ms. Marshalling or unmarshalling takes 0.5 ms per message.

Estimate the time taken by the client to generate and return from 2 requests

  • if it is single-threaded
  • if it has two threads which can make requests concurrently on a single core processor.

Briefly explain your answer.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.