GWT Interview Questions and Answers
by Mohammed, on May 19, 2018 4:13:56 PM
Q1. What is Google Web Toolkit (GWT)?
GWT provides two modes:
- Development Mode: allows to debug the Java code of your application directly via the standard Java debugger.
Q2. What are the Important modules in GWT?
- GWT Compiler
- JRE Emulation library
- Hosted Mode ( Run as java)
Q3. Is GWT works in all the browsers? If yes why?
It means GWT supports Cross browser functionality.
Q4. What are the features of GWT?
Ans: Following are the features of GWT:
- Google Web Toolkit (GWT) is a development toolkit to create RICH Internet Application(RIA).
- GWT provides developers option to write client side application in JAVA.
- GWT is open source, completely free, and used by thousands of developers around the world. It is licensed under the Apache License version 2.0.
Q5. What are the core components of GWT?
Ans: Following are the core components of GWT:
- JRE Emulation library: Google Web Toolkit includes a library that emulates a subset of the Java runtime library. The list includes java.lang, java.lang.annotation, java.math, java.io, java.sql, java.util and java.util.logging.
- GWT UI building library: This part of GWT consists of many subparts which includes the actual UI components, RPC support, History management, and much more.
Q6. Why doesn't GWT provide a synchronous server connection option?
Ans: 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 operators are less convenient to use than synchronous operators, GWT does not provide synchronous operators.
Q7. What is the purpose of ‘source’ tag in *.gwt.xml file in GWT?
Ans: This specifies the names of source folders which GWT compiler will search for source compilation.
Q8. What is the purpose of ‘public’ tag in *.gwt.xml file in GWT?
Ans: The public path is the place in your project where static resources referenced by your GWT module, such as CSS or images, are stored.
Q9. Which widget represents a single line text box in GWT?
Ans: TextBox widget represents a single line text box.
Q10. Which widget represents a password text box in GWT?
Ans: PasswordTextBox widget represents a text box that visually masks its input to prevent eavesdropping.
Q11. Which widget represents a multiline text box in GWT?
Ans: TextArea widget represents a text box that allows multiple lines of text to be entered.
Q12. Which widget represents a rich text editor in GWT?
Ans: RichTextArea widget represents a rich text editor that allows complex styling and formatting.
Q13. Explain bootstrap procedure for GWT application.
Ans: Following are the steps of bootstrap proceure for GWT application when a browser loads the GWT application −
Browser loads the host html page and .nocache.js file.
.nocache.js code resolves deferred binding configuarations (for example, browser detection) and use lookup table generated by GWT compiler to locate one of the .cache.html.
.nocache.js code then creates a html hidden iframe, inserts that iframe into the host page’s DOM, and loads the .cache.html file into the same iframe.
.cache.html contains the actual program of a GWT application and once loaded in iframe shows the GWT application in the browser.
Q14. What are Modules, Entry Points and HTML Pages in GWT?
Ans: GWT applications are described as modules. A module \"modulename\" is described by a configuration file \"modulename.gwt.xml\". Each module can define one or more Entry point classes.
An entry point is the starting point for a GWT application, similar to the main method in a standard Java program. A Java class which is an entry point must implement the interface \"com.google.gwt.core.client.EntryPoint\" which defines the method onModuleLoad().
The module is connected to a HTML page, which is called \"host page\". The code for a GWT web application executes within this HTML document.
The HTML page can define \"div\" containers to which the GWT application can assign UI components or the GWT UI components are simply assigned to the body tag of the HTML page.
Q15. What are the language differences between web mode and hosted mode?
Q16. What is the purpose of the IsSerializable interface in GWT?
Ans: A user-defined class is serializable if all of the following apply:
It is assignable to IsSerializable or Serializable, either because it directly implements one of these interfaces or because it derives from a superclass that does
All non-final, non-transient instance fields are themselves serializable, and
As of GWT 1.5, it must have a default (zero argument) constructor (with any access modifier) or no constructor at all.
One key difference though is that , for security reasons, all Serializable classes must be included in a serialization policy, which is generated at compile time, while IsSerializable classes do not have that requirement.
If your interest is purely in GWT, and you don\'t e.g. share your model classes between the web application and another application, I suggest you have your model classes/DTOs implement IsSerializable.
Q17. What is Gwt Sever Side RemoteServiceServlet?
Ans: Public class Remote Service Servlet extends javax.servlet.http.HttpServletimplements SerializationPolicyProvider
The servlet base class for your RPC service implementations that automatically deserializes incoming requests from the client and serializes outgoing responses for client/server RPCs.
Q18. How GWT Navigation works?
Ans: In GWT we can handle page navigation using couple of ways.
- Using History tokens.
- Clearing the content panel and load the new page in the content panel.
Q19. What 3d party libraries have used with GWT? Which libraries would you recommend? Why?
- GUICE: for Server side dependency injection
- GIN: for client side dependency injection
- GWTP: Model - View - Presenter framework
Q20. Describe how an event bus is used and implemented.
Ans: Create a Classs that extends GWTEvent
Define a new handler and marker interface for the event class.
Register the event using EventBus where you implement interface( the one written inside the event class)
implement the interface method and call the event fire method
Q21. What is Module descriptor in GWT?
Ans: A module descriptor is the configuration file in the form of XML which is used to configure a GWT application. A module descriptor file extension is *.gwt.xml, where * is the name of the application and this file should reside in the project's root.
Q22. How can we run GWT application?
Ans: Two ways of running the application:
- Create a war file and deploy in any app server or
- Run ant hosted in the command prompt. And click on the ‘Launch Default Browser’.
Q23. How to compile the GWT application?
Ans: Run ant build in the root folder of the application
- By default gwt compiler creates optimized JS files for some browsers.
Disadvantage is it takes a lot of time to compile each change because of the permutations
- Open command prompt
- Go to the application root folder
- Run command as \"ant build\"
Then you can see compile logs are coming. If you see BUILD SUCCESSFUL it means no error in your application. If BUILD FAILED it means there is an error in your application.