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.
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
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.
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.
There are two ways to handle exceptions:
AWT are heavy-weight components. Swings are light-weight components. Hence swing works faster than AWT.
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.
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.
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.
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).
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.
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)
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.
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.
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).
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.
Map is Interface and Hashmap is class that implements that.
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.
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.
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.
There must be a suitable node available to act as a mapping origin
There are three exceptions in which serialization does not necessarily read and write to the stream.
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.
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.
Serialization is a mechanism by which you can save the state of an object by converting it to a byte stream.
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.
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.
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
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.
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.
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)
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.
Vector is synchronized whereas arraylist is not.
Program compiles and runs properly.
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.
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.
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.
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.
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.
Program compiles but throws a runtime error “NoSuchMethodError”.
The program compiles properly but at runtime it will give “Main method not public.” message.
The serializable interface is an empty interface; it does not contain any methods. So, we do not implement any methods.
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.
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.
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.