Javatpoint Logo
Javatpoint Logo

GWT Interview Question

1) What is GWT?

Google Web Toolkit (GWT) is a development toolkit for building ajax application using Java. GWT insist on reusable approaches to common web-app tasks such as bookmarking, UI abstraction, cross-browser portability, etc.

GWT provides two modes:

  1. Development Mode: It allows debugging the Java code of the application directly via the standard Java debugger.
  2. Web mode: In this, the application is translated into HTML and JavaScript code. It can be deployed to a web server.

2) What are the components of GWT?

  • GWT Java-to-JavaScript Compiler: It translates all the Java written code into JavaScript.
  • GWT Development Mode: It allows the developers to run the application in development mode, i.e., app run in Java without compiling JavaScript. Development mode allows native mode plug-in called Google Web Toolkit Developer Plug-in.
  • JRE emulation library: GWT includes a library that follows the Java runtime library i.e. java.lang, java.lang.annotation, java.math,, java.sql, java.util etc.
  • GWT Web UI class library: For creating a widget GWT consist of the set of interface and classes.

3) What is a module descriptor in GWT?

A module descriptor is a configuration file used to set-up a GWT application. Its file extension is *.gwt.xml, where * is the name of the application and this file should reside in the project's root.

4) 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 similar.

5) How do I enable assertions?

The GWT compiler recognizes the -ea flag to generate code for assertions in the compiled JavaScript. Only use assertions for debugging purposes, not production logic because assertions will only work under GWT's development mode.

6) What is the default style name of any GWT widget?

By default, the class name for each component is gwt-. For example, the Button widget has a default style of gwt-Button, and similar way TextBox widget has a default style of gwt-TextBox.

7) 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 French for the user accessing the website from France.

8) What is the purpose of Host Page?

The most important public resource is host page which is used to invoke actual GWT application. A typical HTML host page for an application might not include any visible HTML body content at all, but it is always expected to include GWT application via a <script.../> tag.

9) What is RPC?

RPC (Remote Procedure Call) helps in client communication with the server. RPC is a process of calling a method from a class; however, in this process, the only difference is that the class is located on a server but not the part of the client program.

10) What is GWT ClientBundle?

The ClientBundle interface moves entries from the everything-else category into the cache-forever category.

11) What are the types of panels in GWT?

  • Root Panel: It is the topmost panel where all other widgets are attached to it.
  • Flow Panel: It is the simplest panel which provides a basic HTML layout.
  • HTML Panel: It is enclosed with specified HTML contents.
  • Form Panel: It specifies that any widget declared in this would be wrapped in HTML form element.
  • Scroll Panel: It puts all the content in the scrollable area.
  • Grid: It helps to create an HTML table.
  • Flex Table: It extends HTML table like a GRID, but here we can create a table on demand.

12) What are the Layout Panels?

Layout Panels can contain other widgets. These panels control 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 UIObject class.

13) Define GWT JSON?

JSON(JavaScript Object Notation) is a language-independent format for data. It is similar to XML as XML uses tags JSON uses Object-Literal notation of JavaScript.

14) Define Parsing in GWT XML?

To parse the XML, we have to first parse the raw XML text into XML DOM structure. DOM structure helps in the navigation of the data. XML parser is located under XMLParser class. XMLParser class consists of parse(String) static method which is called to parse the XML and return a Document object.

15) Give the nodes created by XML parsing.

  • Element - represents DOM elements, which are specified by tags in XML: <someElement></someElement>.
  • Text - represents the text between the opening and closing tag of an element: <someElement>Here is some text.</someElement>.
  • Comment - represents an XML comment: <!-- notes about this data -->.
  • Attr - represents an attribute of an element: <someElement myAttribute="123" />.

16) Enlist the dependencies required for database in GWT

Common: hsqldb, Common-lang , log4j .

JDO: datanucleus, showfiles, jdo.

Hibernate: hibernate.

MyBatis: mybatis.

17) Define GWT History Mechanism.

History mechanism is similar to the Ajax history implementations such as RSH (Really Simple History). The Basic idea is to track the internal application state in the URL fragment identifier. Main advantages of this mechanism are:

  • It provides browser history reliable.
  • It provides useful feedback to the user.
  • It is bookmarkable, i.e., the user can create a bookmark to the current state and save it or can email it, etc.

18) Define GWT History Tokens.

A token is simply a string that the application can parse to return to a particular state. This token will be saved in browser history as a URL fragment (in the location bar, after the "#"), and this fragment is passed back to the application when the user goes back or forward in history or follows a link.

19) How to create the custom widget?

Google Web Toolkit offers a variety of ways for creating the custom widgets. The easiest way is to develop composite widgets by grouping existing basic widgets and adding some interaction logic to them.

To create a Custom Widget, it has three general concepts which are as follows:

  1. Building Composite Widgets.
  2. Create the Java Code for the new widget.
  3. Wrap JavaScript using JSNI methods.

20) What is JSNI?

JSNI (JavaScript Native Interface) is used to solve problems such as when we need to integrate GWT with existing handwritten JavaScript or with a third-party JavaScript library. Occasionally we need to access low-level browser functionality which is not exposed by the GWT class API's.

21) What are the different uses of JSNI?

JSNI is a web equivalent of inline assembly code and can use in many ways such as:

  • Implement a Java method directly in JavaScript.
  • Wrap type-safe Java method signatures around existing JavaScript.
  • Call from JavaScript code into Java code and vice-versa.
  • Throw exceptions across Java/JavaScript boundaries.
  • Read and write Java fields from JavaScript.
  • Use development mode to debug both Java source (with a Java debugger) and JavaScript (with a script debugger).

You may also like:

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA