Java Multiple Choice Questions & Answers on Remote Method Invocation (RMI) for Freshers

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

Explanation: Remote method invocationor 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
3. Which of these methods are member of Remote class?

a) checkIP()
b) addLocation()
c) AddServer()
d) None of the mentioned
Answer: d

Explanation: Remote class does not define any methods, its pupose 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

Explanation: 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
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.mofify
Answer: a

Explanation: java.text provides capabilities for formatting, searching and manipulating text.
7. What is the output of this program?
  1.     import java.lang.reflect.*;
  2.     class Additional_packages {  
  3.          public static void main(String args[]) {
  4.       try {
  5.           Class c = Class.forName("java.awt.Dimension");
  6.    Constructor constructors[] = c.getConstructors();
  7.    for (int i = 0; i < constructors.length; i++)
  8.        System.out.println(constructors[i]);
  9.    }
  10.       catch (Exception e){
  11.              System.out.print("Exception");
  12.              }
  13.         }
  14.     }
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
8. What is the output of this program?
  1.     import java.lang.reflect.*;
  2.     class Additional_packages {  
  3.          public static void main(String args[]) {
  4.       try {
  5.           Class c = Class.forName("java.awt.Dimension");
  6.    Field fields[] = c.getFields();
  7.    for (int i = 0; i < fields.length; i++)
  8.        System.out.println(fields[i]);
  9.    }
  10.       catch (Exception e){
  11.              System.out.print("Exception");
  12.              }
  13.         }    
  14.     }
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
9. What is the length of the application box made by this program?
  1.     import java.awt.*;
  2.     import java.applet.*;
  3.     public class myapplet extends Applet {
  4.         Graphic g;
  5.         g.drawString("A Simple Applet",20,20);    
  6.     }
a) 20
b) Default value
c) Compilation Error
d) Runtime Error
Answer: c

Explanation: 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 is the output of this program?
  1.     import java.lang.reflect.*;
  2.     class Additional_packages {  
  3.          public static void main(String args[]) {
  4.       try {
  5.           Class c = Class.forName("java.awt.Dimension");
  6.    Method methods[] = c.getMethods();
  7.    for (int i = 0; i < methods.length; i++)
  8.        System.out.println(methods[i]);
  9.    }
  10.       catch (Exception e){
  11.              System.out.print("Exception");
  12.              }
  13.         }
  14.     }
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

Related

Multiple Choice Questions 6166705103831533912

Post a Comment

emo-but-icon

item