Flex Interview Questions with Answer for Experienced Page 1

Flex Interview Questions with Answer Part 1.

1.         Please explain about yourself?
2.         Tell about your current project and roles and responsibilities?

3.         Explain Data Binding in Flex?
            Data binding is the process by which changes in one action script object are reflected in another action script object. (OR) Data binding automatically copies the value of a property of a source object to a property of a destination object when the source property changes.
            Data binding requires a source property, a destination property, and a triggering event that indicates when to copy the data from the source to the destination. An object dispatches the triggering event when the source property changes
            Adobe Flex provides 3 ways to specify Data binding:
            1) Curly braces ({ }) syntax in mxml and [Bindable] metadata tag
            2) <mx: Binding> tag in MXML
            3) BindingUtils.bindProperty/bindSetter methods in Action Script at runtime.
           
4.         Explain Event Life Cycle/Event Phases/Event flow?
            Flex is an event driven programming model. Events let a developer know when something happen within in a flex application. They can be generated by user devices such as the mouse and keyboard or other external inputs such as the return of a webservice call. Events are also triggered when changes happen in the lifecycle of a component such as the creation or destruction of a component.
             The event flow is conceptually divided into 3 parts.
            (1) Capturing Phase    (2) Targeting Phase     (3) Bubbling Phase 
                                    Application
                           HDividedBox
                                                                        ViewStack
                                                            Panel id="medical"
                                                                                                 Button label="Submit"
                                                                                                Panel id="dental"
                                                                                                            Button label="Submit"
            In the above example there are two Submit Buttons — one in the medical Panel and the other in the dental Panel. You can imagine an application that has many forms and many Submit Buttons.
            When the user clicks the Submit Button in the medical Panel, a click event (data type MouseEvent.CLICK) begins its journey within the event framework.
            (1) Capturing Phase:
            The first part of the event flow is called the capturing phase. This phase comprises all of the nodes from the root node to the parent of the target node. During this phase, Flash Player examines each node, starting with the root and stops after it reaches the target node's parent. 
            The capture phase works from the outermost component downward toward the Button. This means the click event is first given to the Application to handle. If the click event is not consumed by the Application, it is given to the HDividedBox. It is then given to the ViewStack and then to the medical Panel
            (2) Targeting phase:
            The second part of the event flow, the targeting phase, consists solely of the target node. Flash Player sets the appropriate values on the Event object, checks the target node for registered event listeners, and then calls those listeners
            (3) Bubbling phase:
            The third part of the event flow, the bubbling phase, comprises all of the nodes from the target node's parent to the root node. .Starting with the target node's parent, Flash Player sets the appropriate values on the Event object and then calls event listeners on each of these nodes. Flash Player stops after calling any listeners on the root node.

5.         What is stopPropagation() and stopImmediatePropagation()? (OR) Difference between stopPropagation and stopImmediatePropagation()? (OR)
How to stop the event flow/ event phases?
            stopPropagation: Prevents processing of any event listeners in nodes subsequent to the current node in the event flow. This method does not affect any event listeners in the current node (current target). 
            stopImmediatePropagation: Prevents processing of any event listeners in the current node and any subsequent nodes in the event flow. This method takes effect immediately and it affects event listeners in the current node.

6.         What is clone() method? 
            Clone method creates duplicate copy of the event class. This method is executed automatically when the event is redispatched in the event listeners.

7.         What is preventDefault () method?
            To cancel the default behaviour of the event. The methods of the Event class can be used in event listener functions to affect the behaviour of the event object. Some events have an associated default behaviour. For example, the doubleClick event has an associated default behaviour that highlights the word under the mouse pointer at the time of the event. Your event listener can cancel this behaviour by calling the preventDefault () method.
            PreventDefault () method will work only if Cancellable property is true, otherwise it’s not working.
           
8.         What is the difference between Target and Current Target?
            Target: The object that dispatched the event (doesn’t change). Target will not change.
             Current Target: The object who is currently being checked for specific event listeners (changes). Current target is keep on change.

9.         How to create Custom Events? Explain the steps to create a new custom event?
            To dispatch a new event from your custom component, you must do the following:
            1.(Optional) Create a subclassfrom the flash.events.Eventclass to create an event class that describes the event object. 
            2.(Optional) Use the [Event]metadata tag to make the event public so that the MXML compiler recognizes it. 
            3.Dispatch the event using the dispatchEvent() method. 

10.       How to enable capturing or Targeting and Bubbling Phases?
11.       How to execute only Targeting phase listeners?

12.       Tell me arguments of addEventListener() method?
            addEventListener (type: string, listener: function, useCapture: Boolean=false, priority:int=0, useWeakReference:Boolean=false):void
            type: Type of Event(MouseClick, MouseOver)
            listener: It’s a function
            useCapture(dfault:false): If True: Enable only Capturing Phase
                                                                                    Flase: Enable Targetting and Bubbling Phase.
            Priority(int=0): The priority level of the listener. The higher the number the higher the priority. 
            useWeakReference(default =false): whether the reference to the listener is strong or weak. A strong reference (default) preventing your listener from being garbage-collected, a weak reference does not.

13.       Explain about cairngorm architecture
                        Cairngorm is an implementation of several design patterns that form a lightweight architectural framework. Cairngorm follows the principle of separating the view and business logic which is known as the Model-View-Controller pattern (MVC).
            The Pieces of Cairngorm:
                        Model Locator, View, Front Controller, Command, Delegate and Service
            Model Locator: Stores all of your application’s Value Objects (data) and shared variables, in one place. Similar to an HTTP Session object, except that its stored client side in the Flex interface instead of server side within a middle tier application server.
            View: One or more Flex components (button, panel, combo box, Tile, etc) bundled together as a named unit, bound to data in the Model Locator, and generating custom Cairngorm Events based on user interaction (clicks, rollovers, drag n drop.)
            Front Controller: Receives Cairngorm Events and maps them to Cairngorm Commands.
            Command: Handles business logic, calls Cairngorm Delegates and/or other Commands, and updates the Value Objects and variables stored in the Model Locator
            Delegate: Created by a Command, they instantiate remote procedure calls (HTTP, Web Services, etc) and hand the results back to that Command.
            Service: Defines the remote procedure calls (HTTP, Web Services, etc) to connect to remote data stores.

14.       Advantages and disadvantages of Cairngorm Framework?
            Advantages:
            (1)        Multiple handlers for a single event.
            DisAdvantages:
            •           The ModelLocator can get huge and unwieldy; depending on how large your application is and how much data it keeps. To resolve this, I have seen using more than one ModelLocator to separate, say, the business data from the presentation data. But it still won’t be fun to handle merge conflicts with everyone updating it, if you’re in a large team.
            •           Extending the CairngormEvent for each event to encapsulate the event name ID and data was not too pleasant. I would imagine it’s easy to end up with duplicate event IDs in a large application (which is why a naming convention would be vital). I suppose you can create a generic Cairngorm event, but the data parameters wouldn’t be type-checked.
            •           Lastly, I wasn’t in favor of referencing the ModelLocator in all of my Flex components. I favored passing a data reference from a parent component to keep my view components as reusable and un-Cairngorm-ish as possible.

15.       Difference between Cairngorm Event and Flex Event?
            Cairngorm Event is not a bubbled event and it can be understand by only flex commands.
            Flex events can be dispatched by every component in Flex.
           
16.       How to add two commands to one single event type?
            Sequence Command is used to add multiple commands to one event type.
17.       Should Model Locator as a singleton class? can't we instantiate this class as like normal class?
            You can call as a normal class because constructor is public.
18.       What is Singleton class? Explain the steps to create a Singleton class?
            The singleton pattern is a design pattern that is used to restrict instantiation of a class to one object. If we create the class as a singleton then no way to create more than one instance. But, we can get that single instance in any number of classes. So all the classes will share the same properties and behaviours of that singleton object.
            Steps to create a Singleton class:
            Consider the MySingleTon class as a singleton class.
            package {
                        public class MySingleTon {

                                    // Single Instance of Our MySingleTon
                                    private static var instance:MySingleTon;

                                    //DEFINE YOUR VARIABLES HERE
                                    public function MySingleTon (enforcer:SingletonEnforcer)
                                    {
                                                if (enforcer == null)
                                                {
                                                             throw new Error( "You Can Only Have One MySingleTon");
                                    }
                                    }

                                    // Returns the Single Instance
                                    public static function getInstance() : MySingleTon
                                    {
                                      if (instance == null)
                                      {
                                                                         instance = new MySingleTon ( new SingletonEnforcer );
                                      }
                                      return instance;
                                    }
                        }
                          }

            // Utility Class to Deny Access to Constructor
            class SingletonEnforcer {}

            1). We should create one static variable. It will be called "instance" and it will be of type MySingleTon. This will be the variable where we will store our one instance of our class.

            2). Then we should create one constructor. The constructor takes one argument - "enforcer". You will notice that this "enforcer" has a type of "SingletonEnforcer" which is defined directly after our class. Here is the logic behind that:
            •           When you put a class in an ActionScript file below the main class, it is only available to that class.
            •           If the constructor requires this argument – then only our main class can create an instance of itself, because we do not have access to the “SingletonEnforcer” class. Only the main class has this access.
            •           We will not access our class in the normal way by using the “new” statement because we can’t call the constructor. Once we get inside of the constructor, we have a few lines that make sure things work as planned. The “if” statement ensures that we had a valid “enforcer” passed in. If there wasn’t it throws an Error stating that “You Can Have Only One MySingleTon”.

19.       Explain about Blaze Ds and Blaze DS services?
            BlazeDS provides a set of services that lets you connect a client-side application to server-side data, and pass data among multiple clients connected to the server. BlazeDS implements real-time messaging between clients.
            Blaze DS services:
            (1)        HTTP Service
            (2)        Webservice
            (3)        Remote Object 
            HTTP Service: HTTP Service components to interact with JSP’s, Servlets and ASP Pages that are not available as Webservice or remoting services destinations.
            <mx:HTTPService id=”myService” url=”http://localhost:8400/middlejava/LoginServlet” result=”resultHandler(event)” fault=faultHandler(event)” method=”Get”/>
            Webservice: Webservice components let you access webservices, which are software modules with methods. Webservices methods are commonly referred to as operations. Webservice interfaces are defined by using XML.
            Flex application can interact with webservices that define their interfaces in a Webservices Description Language (WSDL) document, which is available as a URL. WSDL is a standard format for describing the messages that a webservice understands the format of these responses to those messages.
            <mx: WebService id=”Webservice” wsdl=”http://search.yahoo.com/searchservice?wsdl” result=”resultHandler (event)” fault=faultHandler (event)” method=”Get”/>
            Remote Object: Remote object components let us access the methods of server side java objects, without manually configuring the objects as webservices. We can use remote object components in MXML or ActionScript.
                        We can use RemoteObject components with a standard alone BLAZE DS web application or macromedia ColdFusion MX from Adobe. 

20.       Explain the configuration details of Blaze DS?
            (1)        Add BlazeDS JAR files and dependent JAR files to the WEB-INF/lib directory from BlazeDS project.
            (2)        Add BlazeDS configuration files in the WEB-INF/flex directory from BlazeDS project.
            (3)        Define Message Broker Servlet and a session listener in WEB-INF/web.xml from BlazeDS                project
            The Blaze DS uses four main configuration files namely: 

            1.Services-config.xml: The top level Blaze Ds configuration file, this file usually contains security constraints, channel definitions and logging settings that each of the services can use.
            2.Remoting-config.xml: The remoting service configuration file, which defines remoting service destinations for working with remote objects.
            3.Proxy-config.xml : The proxy service configuration file which defines proxy service destinations for working with webservices and HTTP Service (REST Services)                    
            4.Messaging-config.xml: The messaging service configuration file, which defines messaging service destinations for performing publish subscribe messaging.      

Tags: ,

0 Responses to “Flex Interview Questions with Answer for Experienced Page 1”

Post a Comment

Thanks for your comments

Subscribe

© 2014 Java Frameworks. All rights reserved.
Designed by Blogger