In this article we will learn about the most common interview questions asked in GWT domain. We will start with the basic ones then move on to more tricky ones.
1. What is GWT?
GWT provides two modes:
- Development Mode: allows to debug the Java code of the application directly via the standard Java debugger.
2. What is a module descriptor in GWT application?
A module descriptor is a configuration file used to set-up a GWT application.
3. What is a GWT Module?
A GWT module is simply an encapsulation of functionality. It shares some similarities with a Java package but is not the same thing. A GWT module is named similarly to a Java package in that it follows the usual dotted-path naming convention. For example, most of the standard GWT modules are located underneath “com.google.gwt” However, the similarity between GWT modules and Java packages ends with this naming convention.
A module is defined by an XML descriptor file ending with the extension “.gwt.xml”, and the name of that file determines the name of the module. For example, if we have a file named src/com/mycompany/apps/MyApplication.gwt.xml, then that will create a GWT module named com.mycompany.apps.MyApplication. The contents of the .gwt.xml file specify the precise list of Java classes and other resources that are included in the GWT module.
4. What is an entry point class?
A module entry-point is any class that is assignable to
EntryPoint and that can be constructed without parameters. When a module is loaded, every entry point class is instantiated and its
EntryPoint.onModuleLoad() method gets called.
5. Which method of the Entry point class is called when the GWT application is loaded? What happens if there are multiple Entry point classes?
onModuleLoad(). If there are more than one Entry point classes then each of then gets called in the sequence in which they are defined in the configuration file.
6. How do I enable assertions?
7. What is the default style name of any GWT widget?
By default, the class name for each component is gwt-<classname>. For example, the
Button widget has a default style of
gwt-Button and similar way
TextBox widgest has a default style of
8. What is internationalization?
Internationalization is changing the language of the text based on the locale. For example the browser should display the website content in Hindi for a user sitting in India and in French for the user accessing the website from France.
9. What is the difference between
The related resource types
10. How can you set Browser targeted Compilation in GWT?
To reduce the compilation time, choose favorite browser and add the
user.agent property in the module configuration file.
11. Why doesn’t GWT provide a synchronous server connection option?
GWT’s network operations are all asynchronous, or non-blocking. That is, they return immediately as soon as called, and require the user to use a callback method to handle the results when they are eventually returned from the server. Though in some cases asynchronous operations are less convenient to use than synchronous operations, GWT does not provide synchronous operations.
XMLHTTPRequest also blocks the UI thread, making the browser appear to freeze for the duration of the connection to the server. Some browsers provide a way around this, but there is no universal solution. GWT does not implement a synchronous network connection because to do so would be to introduce a feature that does not work on all browsers, violating GWT’s commitment to no-compromise, cross-browser AJAX. It would also introduce complexity for developers, who would have to maintain two different versions of their communications code in order to handle all browsers.
12. What is GWT
The resources in a deployed GWT application can be roughly categorized into resources to never cache (.nocache.js), to cache forever (.cache.html), and everything else (myapp.css). The
ClientBundle interface moves entries from the everything-else category into the cache-forever category.
13. What is
DataResource in GWT?
DataResource is the simplest of the resource types, offering a URL by which the contents of a file can be retrieved at runtime. The main optimization offered is to automatically rename files based on their contents in order to make the resulting URL strongly-cacheable by the browser. Very small files may be converted into data: URLs on those browsers that support them.
14. How to create custom widgets in GWT?
There are three general strategies to follow:
Create a widget that is a composite of existing widgets. The most effective way to create new widgets is to extend the
Composite class. A composite is a specialized widget that can contain another component (typically, a
Panel) but behaves as if it were its contained widget. We can easily combine groups of existing widgets into a composite that is itself a reusable widget. Some of the UI components provided in GWT are composites: for example, the
TabPanel (a composite of a
TabBar and a
DeckPanel) and the
SuggestBox. Rather than create complex widgets by subclassing
Panel or another Widget type, it’s better to create a composite because a composite usually wants to control which methods are publicly accessible without exposing those methods that it would inherit from its
Create an entirely new widget written in the Java language. It is also possible to create a widget from scratch, although it is trickier since we have to write code at a lower level. Many of the basic widgets are written this way, such as
15. What is a
UiBinder provides a declarative way of defining User Interface. It helps to separate the programming logic from the UI.
16. What is the Same Origin Policy, and how does it affect GWT?
It’s important to note that the SOP issues are not specific to GWT; they are true of any AJAX application or framework.
17. Which class is the superclass of all UI widgets?
18. What is GWT RPC
The GWT RPC framework makes it easy for the client and server components of web application to exchange Java objects over HTTP. The server-side code that gets invoked from the client is often referred to as a service. The implementation of the GWT RPC service is based on a Servlet architecture. Within a client code, we will use a automatically generated proxy class to make calls to the service. GWT will handle serialization of the Java objects. GWT RPC service is different from SOAP and REST.
19. What are Layout Panels?
Layout Panels can contain other widgets. These panels controls the way widget is displayed on User Interface. Every Panel widget inherits properties from
Panel class which in turn inherits properties from
Widget class and which in turn inherits properties from
20. How is GWT different from other frameworks?
GWT provides a set of ready-to-use user interface widgets that we can immediately utilize to create new applications. It also provides a simple way to create innovative widgets by combining the existing ones. We can use IDE to create, debug, and unit-test our AJAX applications. We can build RPC services to provide certain functionalities that can be accessed asynchronously from the web applications easily using the GWT RPC framework.
21. What are the features of GWT
22. What can I do to make images and borders appear to load more quickly the first time they are used?
23. What is Deferred Binding?
Deferred Binding is GWT’s answer to Java reflection. Every web browser has its own idiosyncrasies, usually lots of them. The standard Java way of dealing with idiosyncrasies would be to encapsulate the custom code into subclasses, with one subclass for each supported browser. At runtime, the application would use reflection and dynamic classloading to select the appropriate subclass for the current environment, load the class, create an instance, and then use that instance as the service provider for the duration of the program.
The GWT Compiler uses Deferred Binding to generate a completely separate version of the application for each language.
24. How do I create an app that fills the page vertically when the browser window resizes?
As of GWT 2.0, creating an application that fills the browser is easy using Layout Panels.
LayoutPanels such as
SplitLayoutPanel automatically resize to the size of the window when the browser resizes.
25. How do you make a call to the server if you are not using GWT RPC?
To communicate with the server from the browser without using GWT RPC:
- Create a connection to the server, using the browser’s
- Construct a payload, convert it to a string, and send it to the server over the connection.
- Receive the server’s response payload, and parse it according to the protocol.
26. How can I dynamically fetch JSON feeds from other web domains?
Like all AJAX tools, GWT’s HTTP client and RPC libraries are restricted to only accessing data from the same site where the application was loaded, due to the browser Same Origin Policy. If the application is using JSON, there is a work around to this limitation using a <script> tag (aka JSON-P).
First, we need an external JSON service which can invoke user defined callback functions with the JSON data as argument. An example of such a service is GData’s “alt=json-in-script& callback=myCallback” support. Then, we can use
JsonpRequestBuilder to make our call, in a way similar to a
RequestBuilder when we’re not making a cross-site request.