300+ [LATEST] Java Webdynpro Interview Questions and Answers

Q1. What Is The Basic Difference Between The 2 Approaches To Exception Handling? 1> Try Catch Block And 2> Specifying The Candidate Exceptions In The Throws Clause? When Should You Use Which Approac

In the first approach as a programmer of the method, you urself are dealing with the exception. This is fine if you are in a best position to decide should be done in case of an exception. Whereas if it is not the responsibility of the method to deal with its own exceptions, then do not use this approach. In this case use the second approach. In the second approach, we are forcing the caller of the method to catch the exceptions, that the method is likely to throw. This is often the approach library creators use. They list the exception in the throws clause and we must catch them. You will find the same approach throughout the java libraries we use.

Q2. Are The Imports Checked For Validity At Compile Time? E.g. Will The Code Containing An Import Such As Java.lang.abcd Compile?

Yes, the imports are checked for the semantic validity at compile time. The code containing above line of import will not compile. It will throw an error saying, cannot resolve symbol

symbol: class ABCD

location: package io

import java.io.ABCD;

Q3. What Are Different Types Of Inner Classes?

Nested top-level classes, Member classes, Local classes, Anonymous classes Nested top-level classes- If you declare a class within a class and specify the static modifier, the compiler treats the class just like any other top-level class. Any class outside the declaring class accesses the nested class with the declaring class name acting similarly to a package. eg, outer. Inner. Top-level inner classes implicitly have access only to static variables. There can also be inner interfaces. These are of the nested top-level variety.

Member classes – Member inner classes are just like other member methods and member variables and access to the member class is restricted, just like methods and variables. This me a public member class acts similarly to a nested top-level class. The primary difference between member classes and nested top-level classes is that member classes have access to the specific instance of the enclosing class.

Local classes – Local classes are like local variables, specific to a block of code. Their visibility is only within the block of their declaration. For the class to be useful beyond the declaration block, it would need to implement a more publicly available interface. Because local classes are not members, the modifiers public, protected, private, and static are not usable.

Anonymous classes – Anonymous inner classes extend local inner classes one level further. As anonymous classes have no name, you cannot provide a constructor.

Q4. What Are Checked And Unchecked Exception?

A checked exception is some subclass of Exception (or Exception itself), excluding class Runtime Exception and its subclasses. Making an exception checked forces client programmers to deal with the possibility that the exception will be thrown. eg, IOException thrown by java.io.FileInputStream’s read() method· Unchecked exceptions are Runtime Exception and any of its subclasses. Class Error and its subclasses also are unchecked. With an unchecked exception, however, the compiler doesn’t force client programmers either to catch the exception or declare it in a throws clause. In fact, client programmers may not even know that the exception could be thrown. eg, StringIndexOutOfBoundsException thrown by String’s char At () method· Checked exceptions must be caught at compile time. Runtime exceptions do not need to be. Errors often cannot be.

Q5. What Are The Different Ways To Handle Exceptions?

There are two ways to handle exceptions:

  • By wrapping the desired code in a try block followed by a catch block to catch the exceptions.
  • List the desired exceptions in the throws clause of the method and let the caller of the method handle those exceptions.

Q6. Difference Between Swing And Awt?

AWT are heavy-weight components. Swings are light-weight components. Hence swing works faster than AWT.

Q7. What One Should Take Care Of While Serializing The Object?

One should make sure that all the included objects are also serializable. If any of the objects is not serializable then it throws a Not Serializable Exception.

Q8. What Is Externalizable Interface?

Externalizable is an interface which contains two methods read External and write External. These methods give you a control over the serialization mechanism. Thus, if your class implements this interface, you can customize the serialization process by implementing these methods.

Q9. What Is View Assembly ?

A window defines the super set of all possible views that a Web Dynpro application could require whilst running a particular component. The number of views visible at any one time however, will typically be only a subset of the number of views embedded within the window.

The subset of views rendered at any one time is known as the View Assembly. User interaction followed by subsequent navigation processing will frequently cause this subset of views to change with every server round-trip. The view assembly represents those views seen by the user on their client device after the completion of a particular server round trip.

Q10. How Does The Web Dynpro Framework Decide Which Particular Views Make Up The Current View Assembly ?

When an application is executed for the first time, only those views which have their default flag set to true will belong to the first view assembly.

Thereafter, user navigation will occur and the view assembly will be composed of those views that have been newly instantiated (on account of their inbound plugs being fired), and those views that persist from the previous view assembly (because no outbound navigation took place from them).

Q11. What Is The Common Usage Of Serialization?

Whenever an object is to be sent over the network, objects need to be serialized. Moreover, if the state of an object is to be saved, objects need to be serilazed.

Q12. What Is Final?

A final class can’t be extended ie., final class may not be subclasses. A final method can’t be overridden when its class is inherited. You can’t change value of a final variable (is a constant)

Q13. Define Webdynpro Controller?

Controllers are the active parts of a Web Dynpro component. In the design of Web Dynpro controllers, SAP has made a significant modification to the original MVC concept of a controller.

Q14. Objects Are Passed By Value Or By Reference?

Java only supports pass by value. With objects, the object reference itself is passed by value and so both the original reference and parameter copy both refer to the same object.

Q15. What Are The Types Of Controller? Describe ?

In broad terms, SAP has defined two categories of Web Dynpro controller. The difference between them is simply this: A controller either

Has a visual interface, or

Does not have a visual interface.

SAP has introduced this difference in order to maintain a strict separation between those parts of the business application that display data (typically data consumers), and those parts of the business application that process data (typically data generators).

Q16. What Are Pass By Reference And Pass By Value?

Pass by Reference me the passing the address itself rather than passing the value. Passby Value me passing a copy of the value to be passed.

Q17. What Is Hashmap And Map?

Map is Interface and Hashmap is class that implements that.

Q18. What Is Static In Java?

Static me one per class, not one for each object no matter how many instance of a class might exist. This me that you can use them without creating an instance of a class.Static methods are implicitly final, because overriding is done based on the type of the object, and static methods are attached to a class, not an object. A static method in a superclass can be shadowed by another static method in a subclass, if the original method was not declared final. However, you can’t override a static method with a non-static method. In other words, you can’t change a static method into an instance method in a subclass.

Q19. What Is The Difference Between A Constructor And A Method?

A constructor is a member function of a class that is used to create objects of that class. It has the same name as the class itself, has no return type, and is invoked using the new operator. A method is an ordinary member function of a class. It has its own name, a return type (which may be void), and is invoked using the dot operator.

Q20. What Is The Difference Between An Interface And An Abstract Class?

An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods are implicitly abstract. An interface has all public members and no implementation. An abstract class is a class which may have the usual flavors of class members (private, protected, etc.), but has some abstract methods.

Q21. Before A Mapping Relationship Can Be Established, What Criteria Must Be Met ?

There must be a suitable node available to act as a mapping origin

Q22. What Happens To The Static Fields Of A Class During Serialization?

There are three exceptions in which serialization does not necessarily read and write to the stream.

  • Serialization ignores static fields, because they are not part of any state.
  • Base class fields are only handled if the base class itself is serializable.
  • Trient fields.

Q23. What Is An Abstract Class?

Abstract class must be extended/subclassed (to be useful). It serves as a template. A class that is abstract may not be instantiated (ie, you may not call its constructor), abstract class may contain static data. Any class with an abstract method is automatically abstract itself, and must be declared as such. A class may be declared abstract even if it has no abstract methods. This prevents it from being instantiated.

Q24. What Is An Empty View ?

There is a special type of view known as the empty view. This view requires no manual implementation, neither is it possible to interact with it in any way other than invoking its default inbound plug – show Empty View. If you require one particular area of a view set to be empty, then you should embed the empty view into the view area. You can then treat this view just like any other view you have written, except that calling its inbound plug will cause the corresponding view area to be blanked out. If a view set has had no views manually embedded into one of its view areas, then the empty view will be substituted automatically.

Q25. What Is Serialization?

Serialization is a mechanism by which you can save the state of an object by converting it to a byte stream.

Q26. Describe Synchronization In Respect To Multithreading?

With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchronization, it is possible for one thread to modify a shared variable while another thread is in the process of using or updating same shared variable. This usually leads to significant errors.

Q27. Difference Between Hashmap And Hashtable?

The HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and permits nulls. (HashMap allows null values as key and value whereas Hashtable doesnt allow). HashMap does not guarantee that the order of the map will remain constant over time. HashMap is unsynchronized and Hashtable is synchronized.

Q28. What Is The First Argument Of The String Array In Main Method?

The String array is empty. It does not have any element. This is unlike C/C++ where the first element by default is the program name

Q29. What Is An Iterator?

Some of the collection classes provide traversal of their contents via a java.util.Iterator interface. This interface allows you to walk through a collection of objects, operating on each object in turn. Remember when using Iterators that they contain a snapshot of the collection at the time the Iterator was obtained; generally, it is not advisable to modify the collection itself while traversing an Iterator.

Q30. What Are Recursion Nodes ?

The recursion node is a special type of node used when a node hierarchy with a recursive structure needs to be created. This is needed when, for instance, the depth of the node hierarchy is not known until runtime. Using a recursion node, you can declare that a particular node structure be replicated as a child of itself. A good example here is if your context needs to hold information in the same structure as a file system, containing directories and sub directories.

Q31. If The View Set Concept Is Not Implemented In Web Dynpro For Abap, What Options Are There For Reusing Views ?

In both Web Dynpro for ABAP and Java, there is a specific UI Element called the View Container. This UI element, when added to a view layout, acts as a container for any other view. View Containers can be arranged in large variety of ways in order to achieve the desired layout on the screen.

The views that can be embedded into a View Container UI element are the following:

Any view from the current component

Any visual interface from a child Web Dynpro component

An empty view (supplied automatically by the Web Dynpro runtime)

Q32. What Is A View Set ?

A view set is a visual framework that subdivides the window into predefined areas. Each subdivision of a view set is known as a view area, and multiple views can be embedded into a single View Area.

The following preconfigured view sets are available:

T layout T layout 90o T layout 180o T layout 270o Grid layout Tab strip

Each subdivision within the view set layout is known as a view area.

Q33. Difference Between Vector And Arraylist?

Vector is synchronized whereas arraylist is not.

Q34. What If I Write Static Public Void Instead Of Public Static Void?

Program compiles and runs properly.

Q35. What Is The Difference Between Declaring A Variable And Defining A Variable?

In declaration, we just mention the type of the variable and it’s name. We do not initialize it. But defining me declaration + initialization. e.g String s; is just a declaration while String s = new String (“abcd”); Or String s = “abcd”; are both definitions.

Q36. How Can One Prove That The Array Is Not Null But Empty Using One Line Of Code?

Print args.length. It will print @That me it is empty. But if it would have been null then it would have thrown a Null Pointer Exception on attempting to print args.length.

Q37. How Can You Determine Lifespan Of Custom Controllers ?

The lifespan of a custom controller is determined by a parameter setting made during the design time declaration. It can be either “Framework Controlled” or “On demand”. If you choose “Framework Controlled”, then the Web Dynpro framework will instantiate the custom controller when the component is instantiated. If however, you choose “On demand”, then the Web Dynpro developer must write the coding necessary to instantiate the custom controller.

Each child component usage is instantiated with a unique name that must be defined at design time. During the lifespan of the parent component, a child component may only ever be instantiated once under a given name; however, should it be necessary, you may declare multiple usages of the same child component as long as you specify different usage names.

Q38. What Is Face Less Component ?

It is a component with zero views and zero windows. Such a component is known as a “faceless” component and is useful when a complex unit of functionality requiring no direct user interaction needs to be encapsulated. A good example of a faceless component is the creation of something called a model component. This is not actually a specific Web Dynpro component type; rather it is a standard Web Dynpro component that has been written specifically for the task of interacting with a model object.

Q39. How Is Model-driven Architecture Implemented In Web Dynpro Framework ?

Web dynpro framework uses declarative programming techniques to create a meta-model of the application which is free from back-end and front-end programming languages. Rather the metadata is programming language-neutral and has information stored in XML format. It’s only during run-time that the rendering engine generates the code in html and java script from this meta model of the application. So the design part – which defines the UI and data flow between UI elements – is completely abstracted minimizing the coding (which is required only for implementing business logic).

The model-driven approach helps developer to focus less on coding and technology part and more on the design part of the application – “minimizing coding and maximizing design”. Naturally, the primary focus of business application developer should be the business logic and the technological implementation should not distract him.

Q40. What If I Do Not Provide The String Array As The Argument To The Method?

Program compiles but throws a runtime error “NoSuchMethodError”.

Q41. What If The Main Method Is Declared As Private?

The program compiles properly but at runtime it will give “Main method not public.” message.

Q42. Which Methods Of Serializable Interface Should I Implement?

The serializable interface is an empty interface; it does not contain any methods. So, we do not implement any methods.

Q43. Explain The Concept Of Lazy Data Access?

The Web Dynpro framework has been built to follow the principle of Lazy Data Access. This me that the processing required to generate data will not be invoked until the data is actually needed. When this principle is applied to the architecture of the context, it me that unless there is an attempt to access the data in a singleton child node, then even though the lead selection in the parent node has changed, the child node’s supply function will not be called.

Q44. How Do I Serialize An Object To A File?

The class whose instances are to be serialized should implement an interface Serializable. Then you pass the instance to the Object Output Stream which is connected to a file output stream. This will save the object to a file.

Q45. What Is The Purpose Of Garbage Collection In Java, And When Is It Used?

The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources can be reclaimed and reused. A Java object is subject to garbage collection when it becomes unreachable to the program in which it is used.