Ticker

6/recent/ticker-posts

Advance Java MCQ 200+ || technical asr group || mcq question & answer

 

 Advance Java MCQ questions 

Chapter 1




1.Which of these package contains classes and interfaces for networking?
a) java.io
b) java.util
c) java.net
d) java.network

2.   Which of these is a protocol for breaking and sending packets to an address across a             network?
      a) TCP/IP
      b) DNS
      c) Socket
      d) Proxy Server

3.   How many ports of TCP/IP are reserved for specific protocols?
      a) 10
      b) 1024
      c) 2048
      d) 512

4.    How many bits are in a single IP address?
       a) 8
       b) 16
       c) 32
       d) 64

5.    Which of these class is used to encapsulate IP address and DNS?
       a) DatagramPacket
       b) URL
       c) InetAddress
       d) ContentHandler
                      

Chapter 2

1.Which of the below is not a valid design pattern?
a) Singleton
b) Factory
c) Command
d) Java

 

2.Which of the below is not a valid classification of design pattern?
a) Creational patterns
b) Structural patterns
c) Behavioural patterns
d) Java patterns

 

3. Which design pattern ensures that only one object of particular class gets created?
a) Singleton pattern
b) Filter pattern
c) State pattern
d) Bridge pattern

 

4. Which design pattern suggest multiple classes through which request is passed and multiple but only relevant classes carry out operations on the request?
a) Singleton pattern
b) Chain of responsibility pattern

c) State pattern
d) Bridge pattern

 

5. Which design pattern represents a way to access all the objects in a collection?
a) Iterator pattern
b) Facade pattern
c) Builder pattern
d) Bridge pattern

Chapter 3

1)   In RMI Architecture which layer Intercepts method calls made by the client/redirects these calls to a remote RMI service? 

a. Stub & Skeleton Layer

b. Application Layer

c. Remote Reference Layer

d. Transport Layer

 

2)   Which is an object, acts as a gateway for the client side, all the outgoing requests are routed through it and it resides at the client side and represents the remote object?

a. Stub

b. Skeleton

c. Both A & B

d. None of the above

 

3)   Java supports RMI, RMI Stands for?

a. Random Method Invocation

b. Remote Memory Interface

c. Remote Method Invocation

d. Random Method Invocation

 

4)   An RMI Server is responsible for _______ 

a. Creating an instance of the remote object

b. Exporting the remote object

c. Binding the instance of the remote object to the RMI registry

d. All mentioned above

 

5)   Abbreviate the term DGC?

 

a. Digital Garbage Collection

b. Distributed Garbage Collection

c. Distributed Garbage Connection

d. None of the above

 


Chapter1

1. Which of these class is used to encapsulate IP address and DNS?
a) DatagramPacket
b) URL
c) InetAddress
d) ContentHandler

 

2. What is the output of this program?

1.     import java.net.*;

2.     class networking

3.     {

4.         public static void main(String[] args) throws UnknownHostException

5.         {

6.             InetAddress obj1 = InetAddress.getByName("sanfoundry.com");

7.             InetAddress obj2 = InetAddress.getByName("sanfoundry.com");

8.             boolean x = obj1.equals(obj2);

9.             System.out.print(x);

10.          }

11.      }

a)0
b)1
c)true
d) false

3. What is the output of this program?

1.     import java.net.*;
2.     public class networking 
3.     {
4.         public static void main(String[] args) throws UnknownHostException 
5.         {
6.             InetAddress obj1 = InetAddress.getByName("cisco.com");
7.             InetAddress obj2 = InetAddress.getByName("sanfoundry.com");
8.             boolean x = obj1.equals(obj2); 
9.             System.out.print(x);
10.          }
11.      }

a)0
b)1
c)true
d) false

 

4. What is the output of this program?

1. import java.io.*;  
2. import java.net.*;  
3. public class URLDemo 
4. {  
5.     public static void main(String[] args) 
6.     {  
7.         try 
8.         {  
9.             URL url=new URL("https://www.sanfoundry.com/java-mcq");  
10.              System.out.println("Protocol: "+url.getProtocol());  
11.              System.out.println("Host Name: "+url.getHost());  
12.              System.out.println("Port Number: "+url.getPort());   
13.          } catch(Exception e){System.out.println(e);}  
14.      }  
15.  }

a)Protocol:http
b)HostName:www.sanfoundry.com
c)PortNumber:-1
d) all of the mentioned

 

5. What is the output of this program?

1.     import java.net.*;
2.     class networking 
3.     {
4.         public static void main(String[] args) throws UnknownHostException 
5.         {
6.             InetAddress obj1 = InetAddress.getByName("cisco.com");
7.             System.out.print(obj1.getHostName());
8.         }
9.     }

a)cisco
b)cisco.com
c)www.cisco.com
d) none of the mentioned

Chapter 2

1.Integer.valueOf is an example of Factory pattern.

A).false

B). true

 

2. Which of the following describes the Proxy pattern correctly?

A - In this pattern a class represents functionality of another class.

B - This pattern creates a chain of receiver objects for a request.

C - This pattern provides a way to evaluate language grammar or expression.

D - In this pattern a request is wrapped under an object as command and passed to invoker object.

 

3.  Which type of design patterns concern class and object composition?

A - Creational Design Patterns

B - Structural Design Patterns

C - Behavioral Design Pattern

D - J2EE Design Patterns

 

4.Which of the following pattern is used where we need to treat a group of objects in similar way as a single object?

A - Composite Pattern

B - Facade Pattern

       C - Flyweight Pattern

D - Decorator Pattern

 

5.design pattern is a logical concept ?
a)True
b) False

 

 

Chapter 3

1)   RMI and EJB, provides services to access an object running in another JVM (known as remote object). 

a. True

b. False

2)   In RMI, the objects are passed by _____. 

a. Value

b. Reference

c. Value and Reference

d. None of the above

 

3)   RMI uses a layered architecture; each of the layers could be enhanced or replaced without affecting the rest of the system. 

a. True

b. False

 

4)   What are the exceptions which have to be handled in a RMI client program? 

a. RemoteException

b. NotBoundException

c. MalFormedURLException

d. All mentioned above

 

5)   RMI is a server-side component; It is not required to be deployed on the server. 

a. True

b. False

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

FS17CO002

                                                            Chapter 1

1)   URL is an acronym for? 

a. Uniform Resource Locator

b. Unified Resource Locator

c. Uniform Restore Locator

d. Unified Restore Locator

 

2)   URL stands for Uniform Resource Locator and represents a resource on the World Wide Web, such as a Web page or FTP directory. 

a. True

b. False

 

3)   Which class is used to create servers that listen for either local client or remote client programs? 

a. ServerSockets

b. httpServer

c. httpResponse

d. None of the above

 

4)   Which constructor of DatagramSocket class is used to creates a datagram socket and binds it with the given Port Number? 

a. DatagramSocket(int port)

b. DatagramSocket(int port, InetAddress address)

c. DatagramSocket()

d. None of the above

 

5)   Which methods are commonly used in ServerSocket class? 

a. public OutputStream getOutputStream()

b. public Socket accept()

c. public synchronized void close()

d. None of the above

 

                                                            Chapter 2

 

 

1. What does MVC pattern stands for?
a) Mock View Control
b) Model view Controller
c) Mock View Class
d) Model View Class

 

2. Which design pattern works on data and action taken based on data provided?
a) Command pattern
b) Singleton pattern
c) MVC pattern
d) Facade pattern

 

3. Which of the following is correct about Behavioral design patterns.

A - These design patterns are specifically concerned with communication between objects.

B - These design patterns provide a way to create objects while hiding the creation logic, rather than instantiating objects directly using new opreator.

C - These design patterns concern class and object composition. Concept of inheritance is used to compose interfaces and define ways to compose objects to obtain new functionalities.

D - None of the above.

 

4.  Which of the following describes the Observer pattern correctly?

A - This pattern is used to get a way to access the elements of a collection object in sequential manner without any need to know its underlying representation.

B - This pattern is used to reduce communication complexity between multiple objects or classes.

C - This pattern is used to restore state of an object to a previous state.

D - This pattern is used when there is one-to-many relationship between objects such as if one object is modified, its depenedent objects are to be notified automatically.

 

5.  Which of the following describes the Business Delegate pattern correctly?

A - In this pattern, a visitor class is used which changes the executing algorithm of an element class.

B - This pattern is used to separate application's concerns.

C - This pattern is used to decouple presentation tier and business tier.

D - This pattern is used in EJB persistence mechanism.

 

 

Chapter 3

 

1)   Which package is used for Remote Method Invocation (RMI)? 

a. java.lang.rmi

b. java.lang.reflect

c. java.applet

d. java.rmi

 

2)   Which program obtains a remote reference to one or more remote objects on a server and then invokes methods on them in an RMI application? 

a. Server

b. Client

c. Both A & B

d. None of the above

 

3)   Which objects are used by RMI for communicating with the remote object? 

a. Stub

b. Skeleton

c. Both A & B

d. None of the above

 

4)   RMI Architecture consists of how many layers? 

a. 5

b. 3

c. 4

d. 2

 

5)   Which method in naming class specifies a name to the remote object?

a. bind(string name)

b. rebind(string name)

c. Both A & B

d. None of the above

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

FS17CO004

 

                                                            Chapter 1

 

1)   Which classes are used for connection-less socket programming? 

a. DatagramSocket

b. DatagramPacket

c. Both A & B

d. None of the above

 

2)   Which method of URL class represents a URL and it has complete set of methods to manipulate URL in Java? 

a. java.net.URL

b. java.net.URLConnection

c. Both A & B

d. None of the above

 

3)   Which class is used to create servers that listen for either local client or remote client programs? 

a. ServerSockets

b. httpServer

c. httpResponse

d. None of the above

 

 

4)   Which package provides core functionality? 

a. java.net

b. java.rmi

c. java.lang

d. java.math

 

5)   The DatagramSocket and DatagramPacket classes are not used for connection-less socket programming.

a. True

b. False

 

                                                            Chapter 2

 

1.Which of the following describes the Service Locator pattern correctly?

A - This pattern is used to separate low level data accessing API or operations from high level business services.

B - This pattern is used to provide a centralized request handling mechanism so that all requests will be handled by a single handler.

C - This pattern is used when we want to do some pre-processing / post-processing with request or response of the application.

D - This pattern is used when we want to locate various services using JNDI lookup.

 

2. Which of the following describes the Transfer Object pattern correctly?

A - This pattern creates object without exposing the creation logic to the client and refer to newly created object using a common interface.

B - In this pattern an interface is responsible for creating a factory of related objects without explicitly specifying their classes.

C - This pattern involves a single class which is responsible to create an object while making sure that only single object gets created.

D - This pattern is used when we want to pass data with multiple attributes in one shot from client to server.

 

3.  Which type of design patterns concern class and object composition?

A - Creational Design Patterns

B - Structural Design Patterns

C - Behavioral Design Pattern

D - J2EE Design Patterns

 

4.  Which of the following is the correct list of entities of Transfer Object pattern?

A - Business Object , Transfer Object, Client

B - Service, Context, Service Locator, Cache, Client

C - Business Object , Client

D - Service, Service Locator, Client

 

5.  Which of the following pattern refers to creating duplicate object while keeping performance in mind?

A. Builder Pattern

B. Bridge Pattern

C. Prototype Pattern

D. Filter Patter

 

                                                            Chapter 3

 

1)   1099 is the default port used by RMI Registry. 

a. True

b. False

 

2)   Which is a one-way communication only between the client and the server, which is not only a reliable but also there is no confirmation regarding reaching the message to the destination? 

a. TCP/IP

b. UDP

c. Both A & B

d. None of the above

 

3)   RMI uses which protocol on top of TCP/IP (an analogy is HTTP over TCP/IP)? 

a. Java Remote Method Protocol (JRMP)

b. Internet Inter-ORB Protocol (IIOP)

c. Jinni Extensible Remote Invocation (JERI)

d. All mentioned above

 

4)   Which method of the Naming class (found in java.rmi) is used to update the RMI registry on the server machine?

a. rebind ()

b. lookup()

c. Both A & B

d. None of the above

 

 

5)   What is the built on top of the socket programming?

a. EJB

b. RMI

c. Both A & B

d. None of the above

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

FS17CO005

                                                            Chapter 1

1)   Give the abbrevation of BSD. 

a. Berkeley Software Distribution

b. Berkeley Socket Distribution

c. Berkeley System Distribution

d. None of the above

 

2)   The client in socket programming must know which informations? 

a. IPaddress of Server

b. Port number

c. Both A & B

d. None of the above

 

3)   The URLConnection class can be used to read and write data to the specified resource referred by the URL 

a. True

b. False

 

4)   Datagram is basically an information but there is no guarantee of its content, arrival or arrival time. 

a. True

b. False

 

5)   What does the java.net.InetAddress class represent? 

a. Socket

b. IP Address

c. Protocol

d. MAC Address

 

 

 

                                                                                Chapter 2

 

1.      Which Design Pattern should you use when you want to use an existing class, and its interface does not match the one you need.

a)    Adapter

b)    Decorator

c)      Mediator

d)    Proxy

 

2.      Which Design Pattern should you use when a set of objects communicate in well-defined but complex ways. The resulting interdependencies are unstructured and difficult to understand

a)    Façade

b)    Factory Method

c)     Template Method

d)    Mediator

 

 

3.      Which Design Pattern should you use when a system should be configured with one of multiple families of products

a)    Builder

b)    Abstract Factory

c)     Factory Method

d)    Composite

 

4.    
Which Design Pattern should you use when When an object should be able to notify other objects without making assumptions about who these objects are. In other words, you don't want these objects tightly coupled.

a)     Visitor

b)    Adapter

c)    Observer

d)    Chain Of Responsibility

 

5.      Which Design Pattern should you use when a system should be independent of how its products are created, composed, and represented; and when the classes to instantiate are specified at run-time, for example, by dynamic loading

a)    Prototype

b)    Façade

c)     Abstract Factory

d)    Flyweight

 

                                                            Chapter 3

1)   In RMI which layer defines and supports the invocation semantics of the RMI connection and this layer maintains the session during the method call?

a. The Stub & Skeleton Layer

b. The Application Layer

c. The Remote Reference Layer

d. The Transport Layer

 

2)   In RMI Distributed object applications need to 

a. Locate remote objects

b. Communicate with remote objects

c. Load class definitions for objects that are passed around

d. All mentioned above

 

3)   RMI allows an object to invoke methods on an object running in another JVM 

a. True

b. False

 

4) An RMI Server is responsible for,
a) Creating an instance of the remote object
b) Exporting the remote object
c) Binding the instance of the remote object to the RMI registry
d) All mentioned above

 

5) In RMI Distributed object applications need to do?
a) Locate remote objects
b) Communicate with remote objects
c) Load class definitions for objects that are passed around
d) All mentioned above

 

 

FS17CO008

                                                            Chapter 1

1)   The flush() method of PrintStream class flushes any uncleared buffers in memory

a. True

b. False

 

2)   TCP,FTP,Telnet,SMTP,POP etc. are examples of ?

a. Socket

b. IP Address

c. Protocol

d. MAC Address

 

3)   Which steps occur when establishing a TCP connection between two computers using sockets? 

a. The server instantiates a ServerSocket object, denoting which port number communication is to occur on

b. The server invokes the accept() method of the ServerSocket class. This method waits until a client connects to the server on the given port

c. After the server is waiting, a client instantiates a Socket object, specifying the server name and port number to connect to

d. All of the above

 

4)   In InetAddress class which method returns the host name of the IP Address? 

a. public String getHostName()

b. public String getHostAddress()

c. public static InetAddress getLocalHost()

d. None of the above

 

5) The DatagramSocket and DatagramPacket classes are not used for connection-less socket programming.
A) True
B) False

                                                            Chapter 2

 

1.Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. It lets subclasses redefine certain steps of an algorithm without changing the algorithm structure.

A. Chain of responsibility

B. Template method

C. Interpretor

D. Prototype

 

2. Which design pattern provides a single class which provides simplified methods required by client and delagates call to those methods?

A. Adapter pattern

B. Builder pattern

C. Facade pattern

D. Prototype pattern

 

3.  In which of the following pattern, a visitor class is used which changes the executing algorithm of an element class?

A. Visitor Pattern

B. MVC Pattern

C. Business Delegate Pattern

D. Composite Entity Pattern

 

4. Which of the following Chooses and standardizes patterns for a problem domain promotes software reuse and, hence, quality and productivity?

A. Promoting Communication

B. Streamlining Documentation

C. Increasing Development Efficiency

D. Supporting Software Reuse

 

5. . Attach additional responsibilities to an object dynamically.It provides a flexible alternative to subclassing for extending functionality.

A. Chain of responsibility

B. Adapter

C. Decorator

D. Composite

 

                                                            Chapter 3

 

1) In RMI program the following example shows the,
import java.rmi.*;
public interface Adder extends Remote{

public int add(int x,int y)throws RemoteException;

}
A) Create and start the remote application
B) Create and start the client application
C) Create the remote interface
D) Provide the implementation of the remote interface

2) In RMI program the following two steps are used to,
Either extend the UnicastRemoteObject class,
the exportObject() method of the UnicastRemoteObject class,
A) Provide the Implementation of the remote interface
B) Create the remote interface
C) Create and start the remote application
D) Compile the implementation class and create the stub and skeleton objects using the rmic tool

3) RMI uses a layered architecture; each of the layers could be enhanced or replaced without affecting the rest of the system?
A) True
B) False

4) When the skeleton receives the incoming request, it does the following tasks?
A) It reads the parameter for the remote method
B) It waits for the result
C) It writes and transmits (marshals) the result to the caller
D) It reads (unmarshals) the return value or exception
E) Both A & C

5) In RMI which layer defines and supports the invocation semantics of the RMI connection, this layer maintains the session during the method call?
A) The Stub & Skeleton Layer
B) The Application Layer
C) The Remote Reference Layer
D) The Transport Layer

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

FS17CO009

                                                            Chapter 1

1. ______ are the advantages of hierarchical routing.

A. Flexibility

B. Reliability

C. Scalability

D. Portability

E. None of these

 

2. One of the following the java.net Net Address class represents.

A. Socket

B. Protocol

C. IP Address

D. MAC Address

E. All of these

 

3. ______is the Central Computer powerful than other computers in the network.

A. Server

B. Hub

C. Client

D. Switch

E. Both A and B

 

4. TCP groups a number of bytes together______in a packets.

A. user datagram

B. datagram

C. segment

D. packet

E. None of these 

5. one of the following classes are used for connection-less socket programming?

A. Datagram Socket

B. Datagram Packet

C. Both Datagram Socket

D. Datagram Packet

                                                            Chapter 2

 

­­

1.  A pattern language

A. encompasses a collection of patterns

B. is implemented using hypertext

C. resembles the structure of natural languages

D. None of the above

 

2. Most user interface design patterns fall with in one of ____ categories of patterns.

A. 5

B. 10

C. 25

D. 100

 

3. . Which of the following are levels of design focus that can be used to categorize WebApp patterns?

A. Behavioral patterns

B. Functional patterns

C. Layout patterns

D. Navigation patterns

E. Both b and d

 

4.Which of the following represents The (static) structure and (dynamic) behavior of the pattern?

A. Name
B. Application
C. Consequences
D. Form

 

5.  Define one to many dependency between objects so that when one object change state, all its dependent are notified and updated automatically.

 

A. Chain of responsibility
B. Event Notification
C. Mediator
D. Observer

 

 

                                                            Chapter 3

 

1. The UnicastRemoteObject class provides support for point-to-point active object references using TCP streams?
a) True
b) False

 

2. 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

 

3. Which of these methods are member of Remote class?

a) checkIP()
b) addLocation()

c) AddServer()
d) None of the mentioned

 

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

 

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

 

 

 

 

 

 

 

 

FS17CO011

                                                            Chapter 1

1. one of the following is a path vector routing?

A. exterior gateway protocol

B. inter-domain routing

C. network routing protocol

D. All of these

2. _______is the Machine that places the request to access the data

A. Client Machine

B. Server Machine

C. Request Machine

D. None of these


3. ______is the default port of SMTP.

A. 25

B. 70

C. 80

D. 85

9. ______ Net Ware protocol provides link-state routing.

A. SAP

B. RIP

C. NLSP

D. NCP

5. one of the following applications of the Client and Server Model?  

A. Email

B. Network Printing

C. World Wide Web

D. All of these




                                                            Chapter 2

 

1.  Which of the following is not one of the elements of a design pattern?

A. context

B. environment
C. solution

D. none of this

 

2. Define an interface for creating an object, but let the subclasses decide which class to instantiate. It let the instantiation differ to subclasses.

A. Factory Method
B. Abstract Factory
C. Prototype

D. Builder

 

3.  Define a family of algorithms, encapsulate each one, and make them interchangeable. It lets the algorithm vary independently from clients that use it.

A. Template method
B. Strategy
C. Visitor

D. Decorator

 

4. Encapsulate a request as an object, there by letting you parametrize clients with different requests, queue or log requests, and support undoable operation.

A. Command
B. Decorator
C. Composite

D. Adaptor

 

5.  Which of the following describes the Facade pattern correctly?

A. This pattern allows a user to add new functionality to an existing object without altering its structure

B. This pattern hides the complexities of the system and provides an interface to the client using which the client can access the system

C. This pattern is primarily used to reduce the number of objects created and to decrease memory footprint and increase performance

 

                                                            Chapter 3

 

1. 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

2. What are the layers of RMI Architecture?

a. Stub and Skeleton layer

b. Remote Reference Layer.

c. Transport layer

d. All of the mentioned

 

3. There are minimum three types of protocol implementations RMI should have?

a. True

b. False

 

4. RMI-IIOP is a ______

a. Class

b. Interface

c. Protocol

d. None of the mentioned

 

5. RMI-IIOP supports dynamic downloading of classes?

a. True

b. False

 

 

 

FS17CO012

                                                            Chapter 1

1) Which of these method of DatagramPacket class is used to find the destination address?
 a) findAddress()
 b) getAddress()
 c) Address()
 d) whois()

 

2) Which of these is a return type of getAddress method of DatagramPacket class?
 a) DatagramPacket
 b) DatagramSocket
 c) InetAddress
 d) ServerSocket

 

3) Which of these is a bundle of information passed between machines?
 a) Mime
 b) cache
 c) Datagrams
 d) DatagramSocket
 
4) Which of these class is necessary to implement datagrams?
 a) DatagramPacket
 b) DatagramSocket
 c) All of the mentioned
 d) None of the mentioned
 
5) Which of these method of DatagramPacket is used to find the port number?
 a) port()
 b) getPort()
 c) findPort()
 d) recievePort()
 

                                                            Chapter 2

1.     You design an application for an advertis-ement company, which produces different sort of publications such as books, articles, leaflets, etc.The company publishes those products in many media formats such as printed material, CD, DVD, online websites, etc.How you would model the company products hierarchy (Publications, Media)?

 

a)Use composite design pattern to enable the publication and media hierarchies to be treated in the same way as a single instance of an object.

 

b) Use the adapter design pattern to translates publication interface into a compatible media interface.

 

c) Use bridge design pattern to build separate hierarchies for the publications and the media, to decouple the abstraction from its implementation so that the two can vary independently.

 

2.     Which design pattern you would you use to decouple an abstraction from its implementation so that the two can vary independently?

 

a)      Adapter design pattern

b)     bridge design pattern

c)      Facade design pattern

d)      Composite bridge design pattern

3.     Which pattern is most appropriate when a decision must be made at the time a class is instantiated?

a)    Bridge

b)    Composite

c)    Factory Method

d)    Command

 

4.     Given the following scenario:

You want to create families of related objects, to be used interchangeably to configure you application. What is the most appropriate GoF pattern to use?

 

a)    Chain of Responsibility

b)    Abstract Factory

c)     Builder

d)    Observer

5.     It is also known as Virtual Constructor and it is used to define an interface for creating an objectbut letting the subclass decide which class to instantiate, this pattern is :

 

a)      Builder

b)      Abstract Factory

c)      Prototype

d)     Factory Method

 

                                                            Chapter 3

1) What is the full-form of IIOP ?

a. Internet Inter ORB Protocol

b. Internet Inter ORB Packet

c. Install Inter ORB Packet

d. None of the mentioned

 

2) The Full-form of JERI is _______

a. Java Extensible Remote Invocation

b. Jini Extensible Remote Invocation

c. Java Enterprise Resource Invocation

d. None of the mentioned

 

3) The Naming class provides methods for storing and obtaining references to remote objects in the remote object registry.

a. True

b. False

 

4) How to get all the registered objects in a rmiregistry?
a. Using list method of Naming Class.

b. Using list method of Unicast Remote Object Class.

c. Both  a. and b.

d. None of the mentioned

 

 

5) bind method(String name) binds the specified name to a remote object

a. True

b. False

 

 

FS17CO013

                                                            Chapter 1

1) Which of these method of DatagramPacket is used to obtain the byte array of data contained in a datagram?
 a) getData()
 b) getBytes()
 c) getArray()
 d) recieveBytes()
 
2) Which of these method of DatagramPacket is used to find the length of byte array?
 a) getnumber()
 b) length()
 c) Length()
 d) getLength()
 
3) Which of these class must be used to send a datatgram packets over a connection?
 a) InetAdress
 b) DatagramPacket
 c) DatagramSocket
 d) All of the mentioned
 
4) Which of these method is used to start a server thread?
 a) run()
 b) start()
 c) runThread()
 d) startThread()
 
5) Which of these method is called when http daemon is acting like a normal web server?
 a) Handle()
 b) HandleGet()
 c) handleGet()
 d) Handleget()
 
 

                                                            Chapter 2

 

1.     You want all the clients using class A to use the same instance of class A, what should you do to achieve this goal?

 

a)    mark class A final

b)    mark class A abstract

c)    apply the Singleton pattern to class A

d)    apply the Memento pattern to class A

 

2.     Which pattern to use when more than one object can handle a request, and the handler is unknown?

 

a)    Chain of Responsibility

b)    Command

c)     Strategy

d)    Observer

 

3.     Which is considered an example of Chain of Responsibility Pattern?

 

a)    java.awt.event.ComponentAdapte

b)    The Java Servlet filter framework

c)     javax.jms.QueueConnectionFactory

d)    java.awt.Toolkit

 

4.     It is known as Action or Transaction and is used to encapsulate a request as an object to support rollback, logging, or transaction functionality

 

            a) Chain of Responsibility Pattern

b) Command Pattern

c) Observer Pattern

d) Strategy Pattern

 

5.     java.util.Enumeration is an example of which pattern?

a)    Iterator

b)    Command

c)     Observer

d)    Strategy

 

                                                            Chapter 3

1) A bean consists of general purpose interfaces are:

A. Properties

B. Events

C. Methods

D. All of these

 

2) CORBA is stands for:

A. Common oriented request broker architecture

B. Common object request break architecture

C. Common object request broker architecture

D. Common object request broker access

 

3) The keywords reserved but used in the initial version of Java are

a. union

b. const

c. inner

d. goto

 

4) The rmiregistry command creates and starts a remote object registry on the specified port on the current host.

a. True

b. False

 

5) Which one of the following import statement is correct?

a. java.rmi.registry.LocateRegistry

b. java.registry.LocateRegistry

c. java.rmi.Locateregistry

d. None of the mentioned

 

 

 

 

 

FS17CO014

                                                            Chapter 1

1) Which of these methods of httpd class is used to read data from the stream?
 a) getDta()
 b) GetResponse()
 c) getStream()
 d) getRawRequest()
 
2) Which of these method of httpd class is used to get report on each hit to HTTP server?
 a) log()
 b) logEntry()
 c) logHttpd()
 d) logResponse()
 
3) Which of these method is used to find a URL from the cache of httpd?
 a) findfromCache()
 b) findFromCache()
 c) serveFromCache()
 d) getFromCache()
 
4) Which of these variables stores the number of hits that are successfully served out of cache?
 a) hits
 b) hitstocache
 c) hits_to_cache
 d) hits.to.cache
 
5) Which of these class is used for operating on request from the client to the server?
 a) http
 b) httpDecoder
 c) httpConnection
 d) httpd
 
 

                                                            Chapter 2

 

1.     In the Publish-Subscribe messaging model, the subscribers register themselves in a topic and are notified when new messages arrive to the topic. Which pattern does most describe this model?

a)    Adapter

b)    Notifier

c)    Observer

d)    State

 

2.     A pattern that is intended to provide a means to define a family of algorithms and encapsulate each one as an object for interchangeable use:

 

a)    Strategy Pattern

b)    Abstract Factory Pattern

c)    Visitor Pattern

d)    State Pattern

 

3.     What is the difference between an adapter and a decorator?

a)    The adapter adds no functionalities to the adaptee class, whereas the Decoratorextends the functionality of the object

b)    The adapter is a creational pattern, whereas the decorator is a structural design pattern

c)    Both introduce a level of indirection between a client class and a class it uses

 

4.     Which best defines the use of the Composite Design Pattern?

a)      the Composite design pattern allows the clients to build a complexobject of smaller different ones

b)      the Composite design pattern allows adding and removing functionality dynamically

c)      the Composite design pattern allows the clients to treat individual objects and compositions uniforml

 

5.     It is also known as Wrapper, it is used when subclassing is not possible or practical to add functionality and it is used to add functionality at runtime. This pattern is :

a)    Composite

b)    Adapter

c)    Decorator

d)    Proxy

 

                                                            Chapter 3

1) What is the full-form of API?

a. Application Programming Interface

b. Application Programming Industry

c. Automatic Programming Interface

d. None of the above

 

2) What should be in the empty box ?

a. RMI Registry

b. Naming Class

c. java.io package

d. Exception

3) RMI facilitates communication between:

a. 2 Java programs

b. 2 JVMs

c. 2 Machines

 

4) Which of the following acts as a DNS service for the implementation class objects?

a. Web server

b. Application server

c. RMI Registry

 

5) Which of the following is the tool used to generate the stub and the skeleton?

a. javac.

b. RMI Registry

c. rmic

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

FS17CO017

                                                            Chapter 1

1) Which of these method of httpd class is used to write UrlCacheEntry object into local disk?
 a) writeDiskCache()
 b) writetoDisk()
 c) writeCache()
 d) writeDiskEntry()
 
2) Which of these is an instance variable of class httpd?
 a) port
 b) cache
 c) log
 d) All of the mentioned
 
3) Which of these is an instance variable of httpd that is a Hashtable?
 a) port
 b) cache
 c) log
 d) stopFlag
4) Which of these exception is thrown by URL class’s constructors?
 a) URLNotFound
 b) URLSourceNotFound
 c) MalformedURLException
 d) URLNotFoundException
 
5) Which of these methods is used to know host of an URL?
 a) host()
 b) getHost()
 c) GetHost()
 d) gethost()
 
                                                             Chapter 2
 
 

1.     Big portion of clients are remotely invoking methods in your system, the surface area exposed to clients includes fine-grained methods, which of course causes network overhead.Which pattern would improve your system performance in this case?

a)    Chain of Responsibility Pattern

b)    Facade Pattern

c)     Command Pattern

d)    Adapter Pattern

 

2.     It is a pattern used to minimize memory use by letting similar objects share as much data as possible stored in a sharable object.

a)    Flyweight

b)    Composite

c)    Iterator

d)    Momento

 

3.     Which pattern is utilized in this example ?

Every character object in a word document has data about the graphical representation and the position, but to avoid redundant graphical representation data for objects to the same character, it is advisable to extract out these representation data to one shared object between these objects, and store only the position of each character internally in each object.

 

a)    Abstract Factory

b)    Method Factory

c)     Builder

d)    Flyweight

 

 

4.     What are the consequences of applying the GOF Bridge pattern?

a)    it makes implementing the client code easier by interacting with a single uniform interface

b)    it decouples an abstraction from its implementation so that the two can vary independently

c)    it will decrease the system extesibility

d)    the client code can traverse tree structures of arbitrary depth recursively

 

5.     When would you use the GOF Bridge design pattern? 

a)    to implement lazy loading of expensive objects

b)    to improve system reliability and scalability

c)    to decouple an abstraction from its implementation so that the two can vary independently

d)    to hide the implementation details from the client code of your design

 
                                                             Chapter 3
 
1) The process of transmission of parameters passed to a remote method from client to server and vice-versa is called:
a. Encoding – decoding
b. Parsing
c. Marshalling – Unmarshaling
 
2) How does the client knows about the functionalities accessible using the remote object?
a. Using the implementation class code present on client 
b. Using Stub
c. Using skeleton
 
3) The lease time is controlled by the system property:
a. java.rmi.dgc.leaseValue
b. rmi.leaseValue
c. rmi.dgc,leasePeriod
 
4) The default lease Period is:
a. 10 Mins
b. 15 Mins
c. 20 Mins
 
5) For running a RMI program TCP/IP should be active only on the host.
a. True 
b. False
 
 
 
 
 
 
 
 
 
FS17CO018
                                                             Chapter 1
 
1) Which of these class is used to access actual bits or content information of a URL?
 a) URL
 b) URLDecoder
 c) URLConnection
 d) All of the mentioned
 
2) Which of these class is used to encapsulate IP address and DNS?
 a) DatagramPacket
 b) URL
 c) InetAddress
 d) ContentHandler
 
3) Which of these is wrapper around everything associated with a reply from an http server?
 a) HTTP
 b) HttpResponse
 c) Httpserver
 d) httpserver
 
4) Which of these transfer protocol must be used so that URL can be accessed by URLConnection class object?
 a) http
 b) https
 c) Any Protocol can be used
 d) None of the mentioned
 
 
5) Which of these methods is used to know when was the URL last modified?
 a) LastModified()
 b) getLastModified()
 c) GetLastModified()
 d) getlastModified()()
 

 

                                                            Chapter 2

1.    Which design pattern you would you use to assign more functionality to an object without sub-classing it?

a)    Bridge design pattern

b)    Adapter design pattern

c)    Composite design pattern

d)    Decorator design pattern

 

 

 

2.    Which of the following are participants in the GOF Decorator design pattern?

a)    Abstract Decorato

b)    Virtual Decorator

c)    Concrete Decorator

d)    Component

 

 

 

3.    What are the consequences of applying the GOF Decorator pattern?

a)    it makes the client code easier by interacting with a single uniform interface

b)    the client code can traverse tree structures of arbitrary depth recursively

c)    it will not alter the class inheritance hierarchy to accommodate for the additional functionality

d)    it allows to nest layers of decorators to add more functionality

 

 

4.    When would you use the GOF Decorator design pattern?

a)    to translates an existing class interface into a compatible target interface

b)    to assign more functionality to an object without sub-classing it

c)    to decouple an abstraction from its implementation so that the two can vary independently

 

 

5.    Which design pattern you would you use to decouple the creation procedure of a complex object from it's concrete instance to be able to apply that procedure on variety of implementations.
a) Factory builder design pattern.

b) Method Builder design pattern

c) Builder design pattern

d) Factory method design pattern

 

                                                            Chapter 3

 

1) Stubs and skeletons are to be written by the programmer.

a. True

b. False

 

2) The Registry is a continuously running process on the host.

a. True

b. False

 

3) How many Exceptions does the java.rmi.server package include?

a. 6

b. 9

c. 4

d. 2

 

4) How many interfaces does the java.rmi.server package include?

a. 6

b. 9

c. 4

d. 2

 

5) How many classes does the java.rmi.server package include?

a. 6

b. 9

c. 4

d. 10

 

FS17CO019

                                                            Chapter 1

1) Which of these methods is used to know the type of content used in the URL?
 a) ContentType()
 b) contentType()
 c) getContentType()
 d) GetContentType()
 
2) Which of these class is used to access actual bits or content information of a URL?
 a) URL
 b) URLDecoder
 c) URLConnection
 d) All of the mentioned
 
3) Which of these data member of HttpResponse class is used to store the response from a http server?
 a) status
 b) address
 c) statusResponse
 d) statusCode
 
 
4) Which of these interface abstractes the output of messages from httpd?
 a) LogMessage
 b) LogResponse
 c) Httpdserver
 d) httpdResponse
 
5) Which of these class is used to create servers that listen for either local or remote client programs?
 a) httpServer
 b) ServerSockets
 c) MimeHeader
 d) HttpResponse
 
 
                                                             Chapter 2
 
 

1.     What would lead you to apply the builder design pattern?

a)    To abstract steps of construction of objects so that different implementations

b)    To translates one interface for a class into a compatible interface

c)    To restrict instantiation of a class to one object

 

2.     Which of the following are participants in the builder design pattern?

a)    Builder interface

b)    Constructor Interface

c)    Director Interface

d)    Concrete Builder class

 

3.     What are the consequences of applying the Builder design pattern?

a)    it makes the designed product hierarchies exchangeable

b)    it's easier to introduce new product implementation

c)    it separates the prodcut construction from it's representation

d)    the director has fine control over the product creation procedure

 

 

 

4.     When would you use the GOF builder design pattern?

a)    to build different representations of complex objects based on the concrete implementations of construction procedure

b)    to establish an interface for creating an object, but let the concrete implementations decide which subclass to instantiate

c)     to encapsulate a family of individual factories that have a common theme

 

 

5.     Which design pattern you would you use to control the creation of an object based on a established interface, while allowing the concrete implementation to determine the subclass to construct.

a)    Singleton design pattern

b)    Builder Factory design pattern

c)     Prototype factory design pattern

d)    Factory method design pattern

 
 
                                                             Chapter 3
 
 
1) A remote object is not an instance of the RemoteObject class.
a. True 
b. False
 
2) The RemoteObject class includes:
a. toString()
b. hashCode()
c. clone()
d. All of the mentioned
 

3) RMI is a pure java solution to Remote Procedure Calls (RPC) and is used to create distributed application in java.

a. True

b. False

 

4) Stub and Skeleton objects are used for communication between client and client side.

a. True

b. False

 

4) The rebind method of Naming class is used to bind the remote object to the new name.

a. True

b. False

 
 
 

 

 

 

 

FS17CO020

                                                            Chapter 1

1) Which of these is a standard for communicating multimedia content over email?
 a) http
 b) https
 c) Mime
 d) httpd

 

2) Which of these class is used for operating on request from the client to the server?
 a) http
 b) httpDecoder
 c) httpConnection
 d) httpd

 

3) Which of these method of MimeHeader is used to return the string equivalent of the values stores on MimeHeader?
 a) string()
 b) toString()
 c) convertString()
 d) getString()

 

4) What is the output of this program?
 
1.    import java.net.*;
 
2.    class networking {
 
3.        public static void main(String[] args) throws MalformedURLException {
 
4.            URL obj = new URL("http://www.sanfoundry.com/javamcq");
 
5.            System.out.print(obj.getProtocol());
 
6.        }
 
7.    }
 a) http
 b) https
 c) www
 d) com
 
5) What is the output of this program?
 
1.    import java.net.*;
 
2.    class networking {
 
3.        public static void main(String[] args) throws MalformedURLException {
 
4.            URL obj = new URL("http://www.sanfoundry.com/javamcq");
 
5.            System.out.print(obj.getPort());
 
6.        }
 
7.    }
 
 
 a) 1
 b) 0
 c) -1
 d) garbage value
 

 

                                                            Chapter 2

1.     Which Design Pattern should you use when an application uses a large number of objects and the storage costs are high because of the sheer quantity of objects

a)    Interpreter

b)    Prototype

c)    Decorator 

d)   Flyweight

 

  1.  Which Design Pattern should you use when an object structure contains many classes of objects with differing interfaces, and you want to perform operations on these objects that depend on their concrete classes

a)    Façade

b)    Adapter

c)     Decorator 

d)    Visitor

 

  1.  Which Design Pattern should you use when you want to add responsibilities to individual objects dynamically and transparently, that is, without affecting other objects.

a)    Visitor

b)    Memento 

c)    Decorator

d)    Proxy

 

  1. Which Design Pattern should you use when there must be exactly one instance of a class, and it must be accessible to clients from a wellknown access point.

a)    Bridge

b)    Singleton

c)     Prototype

d)    Factory Method

 

  1.  Which Design Pattern should you use when there is a language to interpret, and you can represent statements in the language as abstract syntax trees.

a)    Interpreter

b)    Singleton

c)    Façade

d)    Composite

 

                                                            Chapter 3

1) The stub consists of

a. An identifier of the remote object to be used

b. Method name which is to be invoked

c. Parameters to the remote JVM

d. All of the Mentioned

 

2) What does this “import java.rmi.*;” imports?

a. All the classes present in java

b. All the classes present in java.rmi

c. All the methods in java.rmi

d. None of the Mentioned

 

3) What does throws RemoteException mean?

a. Throwing a RemoteException

b. Catching a RemoteException

c. Explicitly telling the java compiler to handle RemoteException

 

4) A remote interface extends the interface java.rmi.Remote and declares a set of remote methods

a. True

b. False

 

5) The call to LocateRegistry.getRegistry simply returns an appropriate stub for a registry.

a. True

b. False

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

FS17C0021

                                                            Chapter 1

1. Cookies were originally designed for __________
a) Client-side programming
b) Server-side programming
c) Both Client-side & Server-side programming
d) Wweb programming

 

2. The Cookie manipulation is done using which property?
a) cookie
b) cookies
c) manipulate
d) modify

 

3. Which of the following explains Cookies nature?
a) Non Volatile
b) Volatile
c) Intransient
d) Transient

 

4. Which attribute is used to extend the lifetime of a cookie?
a) higher-age
b) increase-age
c) max-age
d) lifetime

 

5. Which of the following defines the Cookie visibility?
a) document Path
b) localStorage
c) sessionStorage
d) all of the mentioned

 

                                                            Chapter 2

1.    Which Design Pattern should you use when you want to avoid a permanent binding between an abstraction and its implementation. This might be the case, for example, when the implementation must be selected or switched at run-time.

a)    Abstract Factory

b)    Strategy

c)     Template Method

d)    Bridge

 

2.    Which Design Pattern should you use when the construction process must allow different representations for the object that's constructed.

a)    Singleton

b)    Composite

c)     Decorator

d)    Builder

 

3. Which Design Pattern should you use when a snapshot of (some portion of) an object's state must be saved so that it can be restored to that state later, and a direct interface to obtaining the state would expose implementation details and break the object's encapsulation.

a)     State

b)    Memento

c)     Command

d)    Observer

 

 

4.     Which Design Pattern should you use when you want to parameterize objects by an action to perform.

a)    Command

b)    Prototype

c)     Strategy

d)    Builder

 

 

5.     Which Design Pattern should you use when many related classes differ only in their behavior or you need different variants of an algorithm. For example, you might define algorithms reflecting different space/time trade-offs.

a)    Composite

b)    Factory Method

c)     Proxy

d)    Strategy

 

                                                            Chapter 3

1) If no registry is running on TCP port 1099 of the local host when the bind method is invoked, the server will fail with a RemoteException.

a. True

b. False

 

 

 

2) What is the command to start the rmiregistry on windows?

a. rmiregistry

b. start rmiregistry

c. start rmi registry

d. None of the mentioned

 

3) We make a stub file from the '*.class' file with the implementation of the remote interface, not from the '*.java' file.

a. True

b. False

 

 

4) The correct order to make a simple RMI “Hello World” program:

1.     Write the Java sources

2.     Compile and deploy class files

3.     Start the RMI registry, server, and client

a. 1,2,3

b. 2,1,3

c. 3,2,1

d. 3,1,2

 

5) A "server" class in this context, is the class which has a main method that:

a. creates an instance of the remote object implementation, and

b. binds that instance to a name in the rmiregistry.

c. both a and b

d. none of the mentioned

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

FS17CO022

                                                            Chapter 1

1. Which of the following can be used to configure the scope of the Cookie visibility?
a) path
b) domain
c) both path and domain
d) server

 

2. How can you set a Cookie visibility scope to localStorage?
a) /
b) %
c) *
d) //

 

3. Which of the following is a boolean cookie attribute?
a) bool
b) secure
c) lookup
d) domain

 

4. Which of the following function is used as a consequence of not including semicolons, commas or whitespace in the Cookie value?
a) encodeURIComponent()
b) encodeURI()
c) encodeComponent()
d) encode()

 

5. What is the constraint on the data per cookie?
a) 2 KB
b) 1 KB
c) 4 KB
d) 3 KB

                                                            Chapter 2

1.     Which Design Pattern should you use when you want to represent part-whole hierarchies of objects.

a)    Composite

b)    Iterator

c)     Abstract Factory

d)     Flyweight

 

2.     Which Design Pattern should you use when you want to access an aggregate object's contents without exposing its internal representation.

a)    Iterator

b)    Composite

c)     Proxy

d)     Bridge

 

 

 

3.     Which Design Pattern should you use when a class wants its subclasses to specify the objects it creates.

a)    Bridge

b)    Strategy

c)    Factory Method 

d)    Builder

 

4.     Which Design Pattern should you use when to control subclasses extensions. You can define a template method that calls "hook" operations at specific points, thereby permitting extensions only at those points.

a)    State

b)    Strategy

c)    Template Method

d)    Factory Method

 

5.      Which Design Pattern should you use when you want to provide a simple interface to a complex subsystem.

a)    Adapter

b)    Façade

c)      Composite

d)    Abstract Factory

                                                            Chapter 3

1) java.rmi.Server and java.rmi.Registry are class files.

a. True

b. False

 

2) When the skeleton receives the incoming request, it does the following tasks?
a. It reads the parameter for the remote method
b. It waits for the result
c. It writes and transmits (marshals) the result to the called.
d. It reads (unmarshals) the return value or exception
e. Both A & C

 

3) RMI has which of these protocols implementations?
a. Java Remote Method Protocol (JRMP) 
b. Internet Inter-ORB Protocol (IIOP) 
c. Jinni Extensible Remote Invocation (JERI)
d. All mentioned above

 

4) Which of the following is not the Exception from java,rmi package:                              

a. AccessException

b. ArrayIndexOutOfBoundException

c. RemoteException

d. ConnectException

 

5) MarshalledObject in java.rmi is an interface.

a. True

b. False

Post a Comment

0 Comments