250+ TOP MCQs on Remote Method Invocation (RMI) and Answers

This set of Java Multiple Choice Questions & Answers (MCQs) on “Remote Method Invocation (RMI)”.

1. What is Remote method invocation (RMI)?
a) RMI allows us to invoke a method of java object that executes on another machine
b) RMI allows us to invoke a method of java object that executes on another Thread in multithreaded programming
c) RMI allows us to invoke a method of java object that executes parallely in same machine
d) None of the mentioned

Answer: a
Clarification: Remote method invocation RMI allows us to invoke a method of java object that executes on another machine.

2. Which of these package is used for remote method invocation?
a) java.applet
b) java.rmi
c) java.lang.rmi
d) java.lang.reflect

Answer: b
Clarification: None.

3. Which of these methods are member of Remote class?
a) checkIP()
b) addLocation()
c) AddServer()
d) None of the mentioned

Answer: d
Clarification: Remote class does not define any methods, its purpose is simply to indicate that an interface uses remote methods.

4. Which of these Exceptions is thrown by remote method?
a) RemoteException
b) InputOutputException
c) RemoteAccessException
d) RemoteInputOutputException

Answer: a
Clarification: All remote methods throw RemoteException.

5. Which of these class is used for creating a client for a server-client operations?
a) serverClientjava
b) Client.java
c) AddClient.java
d) ServerClient.java

Answer: c
Clarification: None.

6. Which of these package is used for all the text related modifications?
a) java.text
b) java.awt
c) java.lang.text
d) java.text.modify

Answer: a
Clarification: java.text provides capabilities for formatting, searching and manipulating text.

7. What will be the output of the following Java code?

  1.     import java.lang.reflect.*;
  2.     class Additional_packages 
  3.     {	 
  4.          public static void main(String args[]) 
  5.          {
  6. 	     try 
  7.              {
  8. 	         Class c = Class.forName("java.awt.Dimension");
  9. 		 Constructor constructors[] = c.getConstructors();
  10. 		 for (int i = 0; i < constructors.length; i++)
  11. 		     System.out.println(constructors[i]);
  12. 	     }
  13. 	     catch (Exception e)
  14.              {
  15.              System.out.print("Exception");
  16.              }
  17.         }
  18.     }

a) Program prints all the constructors of ‘java.awt.Dimension’ package
b) Program prints all the possible constructors of class ‘Class’
c) Program prints “Exception”
d) Runtime Error

Answer: a
Clarification: None.
Output:

$ javac Additional_packages.java
$ java Additional_packages
public java.awt.Dimension(java.awt.Dimension)
public java.awt.Dimension()
public java.awt.Dimension(int,int)

8. What will be the output of the following Java code?

  1.     import java.lang.reflect.*;
  2.     class Additional_packages 
  3.     {	 
  4.          public static void main(String args[])
  5.          {
  6. 	     try 
  7.              {
  8. 	         Class c = Class.forName("java.awt.Dimension");
  9. 		 Field fields[] = c.getFields();
  10. 		 for (int i = 0; i < fields.length; i++)
  11. 		     System.out.println(fields[i]);
  12. 	     }
  13. 	     catch (Exception e)
  14.              {
  15.              System.out.print("Exception");
  16.              }
  17.         }    
  18.     }

a) Program prints all the constructors of ‘java.awt.Dimension’ package
b) Program prints all the methods of ‘java.awt.Dimension’ package
c) Program prints all the data members of ‘java.awt.Dimension’ package
d) program prints all the methods and data member of ‘java.awt.Dimension’ package

Answer: c
Clarification: None.
Output:

$ javac Additional_packages.java
$ java Additional_packages
public int java.awt.Dimension.width
public int java.awt.Dimension.height

9. What is the length of the application box made in the following Java program?

  1.     import java.awt.*;
  2.     import java.applet.*;
  3.     public class myapplet extends Applet 
  4.     {
  5.         Graphic g;
  6.         g.drawString("A Simple Applet",20,20);    
  7.     }

a) 20
b) Default value
c) Compilation Error
d) Runtime Error

Answer: c
Clarification: To implement the method drawString we need first need to define abstract method of AWT that is paint() method. Without paint() method we cannot define and use drawString or any Graphic class methods.

10. What will be the output of the following Java program?

  1.     import java.lang.reflect.*;
  2.     class Additional_packages
  3.     {	 
  4.          public static void main(String args[])
  5.          {
  6. 	     try
  7.              {
  8. 	         Class c = Class.forName("java.awt.Dimension");
  9. 		 Method methods[] = c.getMethods();
  10. 		 for (int i = 0; i < methods.length; i++)
  11. 		     System.out.println(methods[i]);
  12. 	     }
  13. 	     catch (Exception e)
  14.              {
  15.              System.out.print("Exception");
  16.              }
  17.         }
  18.     }

a) Program prints all the constructors of ‘java.awt.Dimension’ package
b) Program prints all the methods of ‘java.awt.Dimension’ package
c) Program prints all the data members of ‘java.awt.Dimension’ package
d) program prints all the methods and data member of ‘java.awt.Dimension’ package

Answer: b
Clarification: None.
Output:

$ javac Additional_packages.java
$ java Additional_packages
public int java.awt.Dimension.hashCode()
public boolean java.awt.Dimension.equals(java.lang.Object)
public java.lang.String java.awt.Dimension.toString()
public java.awt.Dimension java.awt.Dimension.getSize()
public void java.awt.Dimension.setSize(double,double)
public void java.awt.Dimension.setSize(int,int)
public void java.awt.Dimension.setSize(java.awt.Dimension)
public double java.awt.Dimension.getHeight()
public double java.awt.Dimension.getWidth()
public java.lang.Object java.awt.geom.Dimension2D.clone()
public void java.awt.geom.Dimension2D.setSize(java.awt.geom.Dimension2D)
public final native java.lang.Class java.lang.Object.getClass()
public final native void java.lang.Object.notify()
public final native void java.lang.Object.notifyAll()
public final native void java.lang.Object.wait(long)
public final void java.lang.Object.wait(long,int)
public final void java.lang.Object.wait()

Leave a Reply

Your email address will not be published. Required fields are marked *