0

programming languages Online Quiz - 184

Description: programming languages Online Quiz - 184
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

What is an aspect?

  1. A Java class encapsulating one or more advices.

  2. A child class inheriting properties of parent class

  3. A class that implements an interface

  4. Transaction handling capability of spring framework


Correct Option: A

Struts framework follows

  1. MVC

  2. View Model

  3. Small Talk

  4. Core page


Correct Option: A
  1. session and request

  2. page, request and session

  3. page, request, session and application

  4. request, session and application


Correct Option: C

Which of the following are the scopes defined in spring?

  1. Singleton

  2. Prototype

  3. Converter

  4. Expression


Correct Option: A,B

Hibernate is the best solutions for data centric applications that only uses the stored-procedures to implement the business logic in database.

  1. True

  2. False


Correct Option: B

MVC is a software approach that separates application logic from presentation

  1. True

  2. False


Correct Option: A

What is Service-oriented Architecture (SOA)?

  1. Programming language

  2. Software architecture

  3. UI concept

  4. Networking Standard


Correct Option: B

Which of the following is considered to be guiding principles of SOA?

  1. Reuse

  2. Modularity

  3. Inheritance

  4. Componentization


Correct Option: A,B,D

A service provider is responsible for the business aspects of the published web service, such as pricing

  1. True

  2. False


Correct Option: A

A service provider creates and publishes Web services, together with their interface and access description

  1. True

  2. False


Correct Option: A

A service provider is also known as the “service registry”

  1. True

  2. False


Correct Option: B

Which of the following is a key concept of SOA?

  1. SOAP

  2. International standards

  3. XML

  4. UML


Correct Option: A,B,C

Compact Computers is a small computer assembly company. Their online application allows customers to pick and choose accessories to build their own PCs. The accessories are: i. Processor - 800Mhz, 1Ghz, 1.2Ghz ii. HDD - 40 GB, 60 GB, 80 GB iii. Memory - 128 MB, 256 MB, 512 MB If a computer can have exactly 1 processor, 1 HDD and 1 memory stick, what pattern would be best used here?

  1. Factory Method

  2. Builder

  3. Abstract Factory

  4. Singleton


Correct Option: B

Which of the following are true about the Bridge and Adapter patterns?

  1. The Adapter pattern implements an interface known to its clients and provides an instance of a class not known to its clients.

  2. The Bridge pattern implements an interface known to its clients and provides an instance of a class not known to its clients.

  3. The Adapter pattern creates a separation between abstractions and classes that implement those abstractions.

  4. The Bridge pattern creates a separation between abstractions and classes that implement those abstractions.


Correct Option: A,D

As part of your new application you need to create a custom class loader so that you can implement with custom security. So you need to create objects without knowing the class of the objects or how to create them. What pattern should you use for this?

  1. Abstract factory

  2. Builder

  3. Prototype

  4. Singleton


Correct Option: C

You are creating a web application for an online product ordering system. You will be using data from several different databases and to reduce the load on the databases you have decided to use connection pooling. You have a ConnectionPool class and you want one pool for each database however you will have to connect to a variable number of databases. What pattern should you use?

  1. Abstract factory

  2. Factory Method

  3. Prototype

  4. Singleton


Correct Option: D

You are designing an application to be used to edit photographs. The aim of the application is to provide effects such as converting a color picture to black and white, enlarging certain areas of the print, creating a watercolor effect etc. At the moment the application is structured so that the photographic image is represented by one object, other objects represent each effect and a control object is used to co-ordinate with these objects. When the user selects the color to black and white effect it changes the state of the Color object to Black and White. This then needs to co-ordinate with the control object and apply the effect. Basically as the state of the effects objects changes it need to co-ordinate with the photographic image object.Which design pattern do you use?

  1. Chain of Responsibility

  2. Notifier

  3. Observer

  4. Mediator


Correct Option: D

You are a Computer Science lecturer at a top University. You are giving a presentation of a new piece of software you have written. Basically you have written the next generation spell checker, the reason yours is so good is that it can learn the common typing mistakes of an individual user. You have already sold licenses to many major software vendors and plan to retire in the Sun. However before you go they all require slight changes in the logic to suit their individual needs. What design pattern will help you slightly change the logic in a class to be used in many applications?

  1. Strategy

  2. Adapter

  3. Template Method

  4. Interpreter


Correct Option: C

When would you use the Visitor pattern?

  1. You need two unconnected objects to be able to send messages to each other.

  2. You need two connected objects to be able to send messages to each other.

  3. You need to create a new operation on an object and you will change the classes of elements on which it operates.

  4. You need to create a new operation on an object without changing the classes of elements on which it operates.


Correct Option: D

AI Explanation

To answer this question, you need to understand the Visitor pattern and its purpose.

The Visitor pattern is a behavioral design pattern that allows you to define new operations on a set of classes without changing the classes themselves. It separates the algorithm from the objects it operates on.

Let's go through each option to understand why it is correct or incorrect:

Option A) You need two unconnected objects to be able to send messages to each other. This option is incorrect. The Visitor pattern does not facilitate communication between two unconnected objects. It is primarily used to add new operations to a set of classes without modifying those classes directly.

Option B) You need two connected objects to be able to send messages to each other. This option is incorrect. The Visitor pattern does not facilitate direct communication between connected objects. It is used to add new operations to a set of classes without modifying those classes directly.

Option C) You need to create a new operation on an object and you will change the classes of elements on which it operates. This option is incorrect. The Visitor pattern is specifically designed to avoid changing the classes of elements on which the new operation operates. It allows you to add new operations without modifying the existing classes.

Option D) You need to create a new operation on an object without changing the classes of elements on which it operates. This option is correct. The Visitor pattern is commonly used in situations where you want to add new operations to a set of classes without modifying the classes themselves. It allows you to define a separate visitor class that contains the new operation, which can then be applied to objects of the existing classes.

The correct answer is D. This option is correct because it accurately describes a common use case for the Visitor pattern.

- Hide questions