JSF and AJAX
AJAX and JSF together makes a rich web application. AJAX usage is focused on creating richer user interfaces..
| |||
JSF Ajax components
The custom web tier components for JSF can be developed using AJAX along with JSF...
| |||
Explain how JSF supports AJAX
A JSF component supports the client-side AJAX Java Script and processes the AJAX requests...
| |||
JSF Architecture
JSF developed based on MVC design pattern. Therefore, the applications can be scaled better and well maintained..
| |||
How JSF different from conventional JSP?
In JSP, page navigation and validation should be implemented by developers...
| |||
How the components of JSF are rendered?
Add JSF libraries to an application. Add the .jsp tag libraries in the .jsp page like:...
| |||
How to declare the Navigation Rules for JSF?
A navigation rule specifies the JSF implementation which page need to send back to the browser after submitting a form...
| |||
What is JSF framework?
JSF framework is an API for developing user interface components for web applications...
| |||
What does it mean by rendering of page in JSF?
A JSF page has components that are made with the help of JSF library. The JSF components lke h:form...
| |||
What is JSF, JavaServer Faces?
JavaServer Faces (JSF) is a server side Java technology, developed by Sun Microsystems, in the field of web application development.
What is required for JSF to get started?
Following things required for JSF:
ΓÇó JDK (Java SE Development Kit)
ΓÇó JSF 1.2
ΓÇó Application Server (Tomcat or any standard application server)
ΓÇó Integrated Development Environment (IDE) Ex. Netbeans 5.5, Eclipse 3.2.x, etc.
Once JDK and Application Server is downloaded and configured, one can copy the JSF jar files to JSF project and could just start coding. :-)
If IDE is used, it will make things very smooth and will save your time.
What is JSF architecture?
JSF was developed using MVC (a.k.a Model View Controller) design pattern so that applications can be scaled better with greater maintainability. It is driven by Java Community Process (JCP) and has become a standard. The advantage of JSF is that it’s both a Java Web user – interface and a framework that fits well with the MVC. It provides clean separation between presentation and behavior. UI (a.k.a User Interface) can be created by page author using reusable UI components and business logic part can be implemented using managed beans.
How JSF different from conventional JSP / Servlet Model?
JSF much more plumbing that JSP developers have to implement by hand, such as page navigation and validation. One can think of JSP and servlets as the â€oeassembly languageâ€? under the hood of the high-level JSF framework.
How the components of JSF are rendered? An Example
In an application add the JSF libraries. Further in the .jsp page one has to add the tag library like:
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
Or one can try XML style as well:
Once this is done, one can access the JSF components using the prefix attached. If working with an IDE (a.k.a Integrated Development Environment) one can easily add JSF but when working without them one also has to update/make the faces-config.xml and have to populate the file with classes i.e. Managed Beans between tags
How to declare the Navigation Rules for JSF?
Navigation rules tells JSF implementation which page to send back to the browser after a form has been submitted. For ex. for a login page, after the login gets successful, it should go to Main page, else to return on the same login page, for that we have to code as:
/login.jsp
login
/main.jsp
fail
/login.jsp
from-outcome to be match with action attribute of the command button of the login.jsp as:
Secondly, it should also match with the navigation rule in face-config.xml as
user
core.jsf.LoginBean
session
In the UI component, to be declared / used as:
value attribute refers to name property of the user bean
|
Showing posts with label Interview Question Of Java. Show all posts
Showing posts with label Interview Question Of Java. Show all posts
Friday, 6 January 2017
JSF Interview Questions and Answers - JavaServer Faces
Thursday, 8 December 2016
Why should I uninstall older versions of Java from my system?
This article applies to:
Platform(s): Windows 10, Windows 7, Windows 8, Windows Vista, Windows XP, Windows 2008 Server, Windows Server 2012
The latest version of Java is always the recommended version as it contains feature updates, vulnerability fixes and performance improvements to previous versions. You can confirm that you have the latest version with the Java Verification page or manually checking the Java version.
Should I uninstall older versions of Java?
We highly recommend that you uninstall all older versions of Java from your system.
Keeping old versions of Java on your system presents a serious security risk.
Uninstalling older versions of Java from your system ensures that Java applications will run with the latest security and performance improvements on your system.
How can I remove older versions of Java?
Windows users can safely uninstall older versions of Java:
- when installing Java 8 (8u20 and above) or
- by using the Java uninstall tool or
- by manually uninstalling Java for Windows
How do I remove Java from my computer?
Windows: You can uninstall versions of Java manually in the same way as you would uninstall any other software from your Windows computer. Follow the instructions on manually uninstalling Java for Windows.
» Mac uninstall Java instructions
» Linux uninstall Java instructions
» Mac uninstall Java instructions
» Linux uninstall Java instructions
Do I need older versions of Java?
The latest available version is compatible with the older versions. However, some Java applications (or applets) can indicate that they are dependent on a particular version, and may not run if you do not have that version installed. If an application or web page you access requires an older version of Java, you should report this to the provider/developer and request that they update the application to be compatible with all Java versions.
Sunday, 20 November 2016
OOPS Interview Questions Part 1
1.What are the principle concepts of OOPS?
There are four principle concepts upon which object oriented design and programming rest. They are:
- Abstraction
- Polymorphism
- Inheritance
- Encapsulation (i.e. easily remembered as A-PIE).
2.What is Abstraction?
Abstraction refers to the act of representing essential features without including the background details or explanations.
3.What is Encapsulation?
Encapsulation is a technique used for hiding the properties and behaviors of an object and allowing outside access only as appropriate. It prevents other objects from directly altering or accessing the properties or methods of the encapsulated object.
4.What is the difference between abstraction and encapsulation?
- Abstraction focuses on the outside view of an object (i.e. the interface) Encapsulation (information hiding) prevents clients from seeing it’s inside view, where the behavior of the abstraction is implemented.
- Abstraction solves the problem in the design side while Encapsulation is the Implementation.
- Encapsulation is the deliverables of Abstraction. Encapsulation barely talks about grouping up your abstraction to suit the developer needs.
5.What is Inheritance?
- Inheritance is the process by which objects of one class acquire the properties of objects of another class.
- A class that is inherited is called a superclass.
- The class that does the inheriting is called a subclass.
- Inheritance is done by using the keyword extends.
- The two most common reasons to use inheritance are:
- To promote code reuse
- To use polymorphism
6.What is Polymorphism?
Polymorphism is briefly described as "one interface, many implementations." Polymorphism is a characteristic of being able to assign a different meaning or usage to something in different contexts - specifically, to allow an entity such as a variable, a function, or an object to have more than one form.
7.How does Java implement polymorphism?
(Inheritance, Overloading and Overriding are used to achieve Polymorphism in java).
Polymorphism manifests itself in Java in the form of multiple methods having the same name.
Polymorphism manifests itself in Java in the form of multiple methods having the same name.
- In some cases, multiple methods have the same name, but different formal argument lists (overloaded methods).
- In other cases, multiple methods have the same name, same return type, and same formal argument list (overridden methods).
8.Explain the different forms of Polymorphism.
There are two types of polymorphism one is Compile time polymorphism and the other is run time polymorphism. Compile time polymorphism is method overloading. Runtime time polymorphism is done using inheritance and interface.
Note: From a practical programming viewpoint, polymorphism manifests itself in three distinct forms in Java:
Note: From a practical programming viewpoint, polymorphism manifests itself in three distinct forms in Java:
- Method overloading
- Method overriding through inheritance
- Method overriding through the Java interface
9.What is runtime polymorphism or dynamic method dispatch? |
In Java, runtime polymorphism or dynamic method dispatch is a process in which a call to an overridden method is resolved at runtime rather than at compile-time. In this process, an overridden method is called through the reference variable of a superclass. The determination of the method to be called is based on the object being referred to by the reference variable.
10.What is Dynamic Binding?
Binding refers to the linking of a procedure call to the code to be executed in response to the call. Dynamic binding (also known as late binding) means that the code associated with a given procedure call is not known until the time of the call at run-time. It is associated with polymorphism and inheritance.
11.What is method overloading?
Method Overloading means to have two or more methods with same name in the same class with different arguments. The benefit of method overloading is that it allows you to implement methods that support the same semantic operation but differ by argument number or type.
Note:
Note:
- Overloaded methods MUST change the argument list
- Overloaded methods CAN change the return type
- Overloaded methods CAN change the access modifier
- Overloaded methods CAN declare new or broader checked exceptions
- A method can be overloaded in the same class or in a subclass
12.What is method overriding?
Method overriding occurs when sub class declares a method that has the same type arguments as a method declared by one of its superclass. The key benefit of overriding is the ability to define behavior that’s specific to a particular subclass type.
Note:
Note:
- The overriding method cannot have a more restrictive access modifier than the method being overridden (Ex: You can’t override a method marked public and make it protected).
- You cannot override a method marked final
- You cannot override a method marked static
13.What are the differences between method overloading and method overriding?
Overloaded Method | Overridden Method | |
---|---|---|
Arguments | Must change | Must not change |
Return type | Can change | Can’t change except for covariant returns |
Exceptions | Can change | Can reduce or eliminate. Must not throw new or broader checked exceptions |
Access | Can change | Must not make more restrictive (can be less restrictive) |
Invocation | Reference type determines which overloaded version is selected. Happens at compile time. | Object type determines which method is selected. Happens at runtime. |
14.Can overloaded methods be override too?
Yes, derived classes still can override the overloaded methods. Polymorphism can still happen. Compiler will not binding the method calls since it is overloaded, because it might be overridden now or in the future.
15.Is it possible to override the main method?
NO, because main is a static method. A static method can't be overridden in Java.
16.How to invoke a superclass version of an Overridden method?
To invoke a superclass method that has been overridden in a subclass, you must either call the method directly through a superclass instance, or use the super prefix in the subclass itself. From the point of the view of the subclass, the super prefix provides an explicit reference to the superclass' implementation of the method.
// From subclass super.overriddenMethod();
17.What is super?
super
is a keyword which is used to access the method or member variables from the superclass. If a method hides one of the member variables in its superclass, the method can refer to the hidden variable through the use of the super keyword. In the same way, if a method overrides one of the methods in its superclass, the method can invoke the overridden method through the use of the super keyword.Note:
- You can only go back one level.
- In the constructor, if you use super(), it must be the very first code, and you cannot access any
this.xxx
variables or methods to compute its parameters.
18.How do you prevent a method from being overridden?
To prevent a specific method from being overridden in a subclass, use the final modifier on the method declaration, which means "this is the final implementation of this method", the end of its inheritance hierarchy.
public final void exampleMethod() { // Method statements }
19.What is an Interface?
An interface is a description of a set of methods that conforming implementing classes must have.
Note:
Note:
- You can’t mark an interface as final.
- Interface variables must be static.
- An Interface cannot extend anything but another interfaces.
- 20.Can we instantiate an interface?You can’t instantiate an interface directly, but you can instantiate a class that implements an interface.
21.Can we create an object for an interface?Yes, it is always necessary to create an object implementation for an interface. Interfaces cannot be instantiated in their own right, so you must write a class that implements the interface and fulfill all the methods defined in it.
22.Do interfaces have member variables?Interfaces may have member variables, but these are implicitlypublic, static,
andfinal
- in other words, interfaces can declare only constants, not instance variables that are available to all implementations and may be used as key references for method arguments for example.
23.What modifiers are allowed for methods in an Interface?Onlypublic
andabstract
modifiers are allowed for methods in interfaces.
24.What is a marker interface?Marker interfaces are those which do not declare any required methods, but signify their compatibility with certain operations. Thejava.io.Serializable
interface andCloneable
are typical marker interfaces. These do not contain any methods, but classes must implement this interface in order to be serialized and de-serialized.
25.What is an abstract class?Abstract classes are classes that contain one or more abstract methods. An abstract method is a method that is declared, but contains no implementation.
Note:- If even a single method is abstract, the whole class must be declared abstract.
- Abstract classes may not be instantiated, and require subclasses to provide implementations for the abstract methods.
- You can’t mark a class as both abstract and final.
26.Can we instantiate an abstract class?An abstract class can never be instantiated. Its sole purpose is to be extended (subclassed).
27.What are the differences between Interface and Abstract class?Abstract Class Interfaces An abstract class can provide complete, default code and/or just the details that have to be overridden. An interface cannot provide any code at all,just the signature. In case of abstract class, a class may extend only one abstract class. A Class may implement several interfaces. An abstract class can have non-abstract methods. All methods of an Interface are abstract. An abstract class can have instance variables. An Interface cannot have instance variables. An abstract class can have any visibility: public, private, protected. An Interface visibility must be public (or) none. If we add a new method to an abstract class then we have the option of providing default implementation and therefore all the existing code might work properly. If we add a new method to an Interface then we have to track down all the implementations of the interface and define implementation for the new method. An abstract class can contain constructors . An Interface cannot contain constructors . Abstract classes are fast. Interfaces are slow as it requires extra indirection to find corresponding method in the actual class.
28.When should I use abstract classes and when should I use interfaces?Use Interfaces when…- You see that something in your design will change frequently.
- If various implementations only share method signatures then it is better to use Interfaces.
- you need some classes to use some methods which you don't want to be included in the class, then you go for the interface, which makes it easy to just implement and make use of the methods defined in the interface.
Use Abstract Class when…- If various implementations are of the same kind and use common behavior or status then abstract class is better to use.
- When you want to provide a generalized form of abstraction and leave the implementation task with the inheriting subclass.
- Abstract classes are an excellent way to create planned inheritance hierarchies. They're also a good choice for nonleaf classes in class hierarchies.
29.When you declare a method as abstract, can other nonabstract methods access it?Yes, other nonabstract methods can access a method that you declare as abstract.
30.Can there be an abstract class with no abstract methods in it?Yes, there can be an abstract class without abstract methods.
Wednesday, 20 July 2016
ADVANCE JAVA BASIC INTERVIEW QUESTION PART 4
151. What is the difference between the File and RandomAccessFile classes?
The File class encapsulates the files and directories of the local file system. The RandomAccessFile class provides the methods needed to directly access data contained in any part of a file.
152. What happens when you add a double value to a String?
The result is a String object.
153. What is your platform's default character encoding?
If you are running Java on English Windows platforms, it is probably Cp1252. If you are running Java on English Solaris platforms, it is most likely 8859_1.
154. Which package is always imported by default?
The java.lang package is always imported by default.
155. What interface must an object implement before it can be written to a stream as an object?
An object must implement the Serializable or Externalizable interface before it can be written to a stream as an object.
156. How are this and super used?
this is used to refer to the current object instance. super is used to refer to the variables and methods of the superclass of the current object instance
157. What is a compilation unit?
A compilation unit is a Java source code file.
158. What interface is extended by AWT event listeners?
All AWT event listeners extend the java.util.EventListener interface.
159. What restrictions are placed on method overriding?
Overridden methods must have the same name, argument list, and return type. The overriding method may not limit the access of the method it overrides. The overriding method may not throw any exceptions that may not be thrown by the overridden method.
160. How can a dead thread be restarted?
A dead thread cannot be restarted.
161. What happens if an exception is not caught?
An uncaught exception results in the uncaughtException() method of the thread's ThreadGroup being invoked, which eventually results in the termination of the program in which it is thrown.
162. What is a layout manager?
A layout manager is an object that is used to organize components in a container
163. Which arithmetic operations can result in the throwing of an ArithmeticException?
Integer / and % can result in the throwing of an ArithmeticException.
164. What are three ways in which a thread can enter the waiting state?
A thread can enter the waiting state by invoking its sleep() method, by blocking on I/O, by unsuccessfully attempting to acquire an object's lock, or by invoking an object's wait() method. It can also enter the waiting state by invoking its (deprecated) suspend() method.
165. Can an abstract class be final?
An abstract class may not be declared as final.
166. What is the ResourceBundle class?
The ResourceBundle class is used to store locale-specific resources that can be loaded by a program to tailor the program's appearance to the particular locale in which it is being run.
167. What happens if a try-catch- finally statement does not have a catch clause to handle an exception that is thrown within the body of the try statement?
The exception propagates up to the next higher level try-catch statement (if any) or results in the program's termination.
168. What is numeric promotion?
Numeric promotion is the conversion of a smaller numeric type to a larger numeric type, so that integer and floating-point operations may take place. In numerical promotion, byte, char, and short values are converted to int values. The int values are also converted to long values, if necessary. The long and float values are converted to double values, as required
169. What is the difference between a Scrollbar and a ScrollPane?
A Scrollbar is a Component, but not a Container. A ScrollPane is a Container. A ScrollPane handles its own events and performs its own scrolling.
170. What is the difference between a public and a non-public class?
A public class may be accessed outside of its package. A non-public class may not be accessed outside of its package.
171. To what value is a variable of the boolean type automatically initialized?
The default value of the boolean type is false.
172. Can try statements be nested?
Try statements may be tested.
173. What is the difference between the prefix and postfix forms of the ++ operator?
The prefix form performs the increment operation and returns the value of the increment operation. The postfix form returns the current value all of the expression and then performs the increment operation on that value.
174. What is the purpose of a statement block?
A statement block is used to organize a sequence of statements as a single statement group
175. What is a Java package and how is it used?
A Java package is a naming context for classes and interfaces. A package is used to create a separate name space for groups of classes and interfaces. Packages are also used to organize related classes and interfaces into a single API unit and to control accessibility to these classes and interfaces.
176. What modifiers may be used with a top-level class?
A top-level class may be public, abstract, or final.
177. What are the Object and Class classes used for?
The Object class is the highest-level class in the Java class hierarchy. The Class class is used to represent the classes and interfaces that are loaded by a Java program..
178. How does a try statement determine which catch clause should be used to handle an exception?
When an exception is thrown within the body of a try statement, the catch clauses of the try statement are examined in the order in which they appear. The first catch clause that is capable of handling the exception is executed. The remaining catch clauses are ignored.
179. Can an unreachable object become reachable again?
An unreachable object may become reachable again. This can happen when the object's finalize() method is invoked and the object performs an operation which causes it to become accessible to reachable objects.
180. When is an object subject to garbage collection?
An object is subject to garbage collection when it becomes unreachable to the program in which it is used
181. What method must be implemented by all threads?
All tasks must implement the run() method, whether they are a subclass of Thread or implement the Runnable interface.
182. What methods are used to get and set the text label displayed by a Button object?
getLabel() and setLabel().
183. Which Component subclass is used for drawing and painting?
Canvas
184. What are synchronized methods and synchronized statements?
Synchronized methods are methods that are used to control access to an object. A thread only executes a synchronized method after it has acquired the lock for the method's object or class. Synchronized statements are similar to synchronized methods. A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement.
185. What are the two basic ways in which classes that can be run as threads may be defined?
A thread class may be declared as a subclass of Thread, or it may implement the Runnable interface.
186. What are the problems faced by Java programmers who don't use layout managers?
Without layout managers, Java programmers are faced with determining how their GUI will be displayed across multiple windowing systems and finding a common sizing and positioning that will work within the constraints imposed by each windowing system
Tuesday, 19 July 2016
ADVANCE JAVA BASIC INTERVIEW QUESTION PART 3
101. Is "abc" a primitive value?
The String literal "abc" is not a primitive value. It is a String object.
102. What is the relationship between an event-listener interface and an event-adapter class?
An event-listener interface defines the methods that must be implemented by an event handler for a particular kind of event. An event adapter provides a default implementation of an event-listener interface
103. What restrictions are placed on the values of each case of a switch statement?
During compilation, the values of each case of a switch statement must evaluate to a value that can be promoted to an int value.
104. What modifiers may be used with an interface declaration?
An interface may be declared as public or abstract.
105. Is a class a subclass of itself?
A class is a subclass of itself.
106. What is the highest-level event class of the event-delegation model?
The java.util.EventObject class is the highest-level class in the event-delegation class hierarchy.
107. What event results from the clicking of a button?
The ActionEvent event is generated as the result of the clicking of a button.
108. How can a GUI component handle its own events?
A component can handle its own events by implementing the required event-listener interface and adding itself as its own event listener.
109. How are the elements of a GridBagLayout organized?
The elements of a GridBagLayout are organized according to a grid. However, the elements are of different sizes and may occupy more than one row or column of the grid. In addition, the rows and columns may have different sizes.
110. What advantage do Java's layout managers provide over traditional windowing systems?
Java uses layout managers to lay out components in a consistent manner across all windowing platforms. Since Java's layout managers aren't tied to absolute sizing and positioning, they are able to accomodate platform-specific differences among windowing systems.
111. What is the Collection interface?
The Collection interface provides support for the implementation of a mathematical bag - an unordered collection of objects that may contain duplicates.
112. What modifiers can be used with a local inner class?
A local inner class may be final or abstract.
113. What is the difference between static and non-static variables?
A static variable is associated with the class as a whole rather than with specific instances of a class. Non-static variables take on unique values with each object instance.
114. What is the difference between the paint() and repaint() methods?
The paint() method supports painting via a Graphics object. The repaint() method is used to cause paint() to be invoked by the AWT painting thread.
115. What is the purpose of the File class?
The File class is used to create objects that provide access to the files and directories of a local file system.
116. Can an exception be rethrown?
Yes, an exception can be rethrown.
117. Which Math method is used to calculate the absolute value of a number?
The abs() method is used to calculate absolute values.
118. How does multithreading take place on a computer with a single CPU?
The operating system's task scheduler allocates execution time to multiple tasks. By quickly switching between executing tasks, it creates the impression that tasks execute sequentially.
119. When does the compiler supply a default constructor for a class?
The compiler supplies a default constructor for a class if no other constructors are provided.
120. When is the finally clause of a try-catch- finally statement executed?
The finally clause of the try-catch- finally statement is always executed unless the thread of execution terminates or an exception occurs within the execution of the finally clause.
121. Which class is the immediate superclass of the Container class?
Component
122. If a method is declared as protected, where may the method be accessed?
A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared.
123. How can the Checkbox class be used to create a radio button?
By associating Checkbox objects with a CheckboxGroup.
124. Which non-Unicode letter characters may be used as the first character of an identifier?
The non-Unicode letter characters $ and _ may appear as the first character of an identifier
125. What restrictions are placed on method overloading?
Two methods may not have the same name and argument list but different return types.
126. What happens when you invoke a thread's interrupt method while it is sleeping or waiting?
When a task's interrupt() method is executed, the task enters the ready state. The next time the task enters the running state, an InterruptedException is thrown
127. What is casting?
There are two types of casting, casting between primitive numeric types and casting between object references. Casting between numeric types is used to convert larger values, such as double values, to smaller values, such as byte values. Casting between object references is used to refer to an object by a compatible class, interface, or array type reference.
128. What is the return type of a program's main() method?
A program's main() method has a void return type.
129. Name four Container classes.
Window, Frame, Dialog, FileDialog, Panel, Applet, or ScrollPane
130. What is the difference between a Choice and a List?
A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices. Only one item may be selected from a Choice. A List may be displayed in such a way that several List items are visible. A List supports the selection of one or more List items.
131. What class of exceptions are generated by the Java run-time system?
The Java runtime system generates RuntimeException and Error exceptions.
132. What class allows you to read objects directly from a stream?
The ObjectInputStream class supports the reading of objects from input streams
133. What is the difference between a field variable and a local variable?
A field variable is a variable that is declared as a member of a class. A local variable is a variable that is declared local to a method.
134. Under what conditions is an object's finalize() method invoked by the garbage collector?
The garbage collector invokes an object's finalize() method when it detects that the object has become unreachable.
135. What is the relationship between a method's throws clause and the exceptions that can be thrown during the method's execution?
A method's throws clause must declare any checked exceptions that are not caught within the body of the method.
136. What is the difference between the JDK 1.02 event model and the event-delegation model introduced with JDK 1.1?
The JDK 1.02 event model uses an event inheritance or bubbling approach. In this model, components are required to handle their own events. If they do not handle a particular event, the event is inherited by (or bubbled up to) the component's container. The container then either handles the event or it is bubbled up to its container and so on, until the highest-level container has been tried.
In the event-delegation model, specific objects are designated as event handlers for GUI components. These objects implement event-listener interfaces. The event-delegation model is more efficient than the event-inheritance model because it eliminates the processing required to support the bubbling of unhandled events.
137. How is it possible for two String objects with identical values not to be equal under the == operator?
The == operator compares two objects to determine if they are the same object in memory. It is possible for two String objects to have the same value, but located indifferent areas of memory.
138. Why are the methods of the Math class static?
So they can be invoked as if they are a mathematical code library
139. What Checkbox method allows you to tell if a Checkbox is checked?
getState().
140. What state is a thread in when it is executing?
An executing thread is in the running state.
141. What are the legal operands of the instanceof operator?
The left operand is an object reference or null value and the right operand is a class, interface, or array type.
142. How are the elements of a GridBagLayout organized?
The elements of a GridBagLayout are of equal size and are laid out using the squares of a grid.
143. What an I/O filter?
An I/O filter is an object that reads from one stream and writes to another, usually altering the data in some way as it is passed from one stream to another.
144. If an object is garbage collected, can it become reachable again?
Once an object is garbage collected, it ceases to exist. It can no longer become reachable again
145. What is the Set interface?
The Set interface provides methods for accessing the elements of a finite mathematical set. Sets do not allow duplicate elements.
146. What classes of exceptions may be thrown by a throw statement?
A throw statement may throw any expression that may be assigned to the Throwable type.
147. What are E and PI?
E is the base of the natural logarithm and PI is mathematical value pi.
148. Are true and false keywords?
The values true and false are not keywords.
149. What is a void return type?
A void return type indicates that a method does not return a value.
150. What is the purpose of the enableEvents() method?
The enableEvents() method is used to enable an event for a particular object. Normally, an event is enabled when a listener is added to an object for a particular event. The enableEvents() method is used by objects that handle events by overriding their event-dispatch methods.
Monday, 18 July 2016
ADVANCE JAVA BASIC INTERVIEW QUESTION PART 2
51. Name three subclasses of the Component class.
Box.Filler, Button, Canvas, Checkbox, Choice, Container, Label, List, Scrollbar, or TextComponent.
51. Name three subclasses of the Component class.
Box.Filler, Button, Canvas, Checkbox, Choice, Container, Label, List, Scrollbar, or TextComponent.
52. What is the GregorianCalendar class?
The GregorianCalendar class provides support for traditional Western calendars.
53. Which Container method is used to cause a container to be laid out and redisplayed?
validate() method is used to cause a container to be laid out and redisplayed.
54. What is the purpose of the Runtime class?
The purpose of the Runtime class is to provide access to the Java runtime system.
55. How many times may an object's finalize() method be invoked by the garbage collector?
An object's finalize() method may only be invoked once by the garbage collector.
56. What is the purpose of the finally clause of a try-catch- finally statement?
The finally clause is used to provide the capability to execute code no matter whether or not an exception is thrown or caught.
57. What is the argument type of a program's main() method?
A program's main() method takes an argument of the String[] type.
58. Which Java operator is right associative?
The = operator is right associative.
59. Can a double value be cast to a byte?
Yes, a double value can be cast to a byte.
60. What must a class do to implement an interface?
It must provide all of the methods in the interface and identify the interface in its implements clause
61. What method is invoked to cause an object to begin executing as a separate thread?
The start() method of the Thread class is invoked to cause an object to begin executing as a separate thread.
62. Name two subclasses of the TextComponent class.
TextField and TextArea
63. Which containers may have a MenuBar?
Frame.
64. How are commas used in the intialization and iteration parts of a for statement?
Commas are used to separate multiple statements within the initialization and iteration parts of a for statement.
65. What is the purpose of the wait(), notify(), and notifyAll() methods?
The wait(), notify(), and notifyAll() methods are used to provide an efficient way for threads to wait for a shared resource. When a thread executes an object's wait() method, it enters the waiting state. It only enters the ready state after another thread invokes the object's notify() or notifyAll() methods..
66. What is an abstract method?
An abstract method is a method whose implementation is deferred to a subclass
67. How are Java source code files named?
A Java source code file takes the name of a public class or interface that is defined within the file. A source code file may contain at most one public class or interface. If a public class or interface is defined within a source code file, then the source code file must take the name of the public class or interface. If no public class or interface is defined within a source code file, then the file must take on a name that is different than its classes and interfaces. Source code files use the .java extension.
68. What is the relationship between the Canvas class and the Graphics class?
A Canvas object provides access to a Graphics object via its paint() method.
69. What are the high-level thread states?
The high-level thread states are ready, running, waiting, and dead.
70. What value does read() return when it has reached the end of a file?
The read() method returns -1 when it has reached the end of a file.
71. Can a Byte object be cast to a double value?
No. An object cannot be cast to a primitive value.
72. What is the difference between a static and a non-static inner class?
A non-static inner class may have object instances that are associated with instances of the class's outer class. A static inner class does not have any object instances.
73. What is the difference between the String and StringBuffer classes?
String objects are constants. StringBuffer objects are not constants.
74. If a variable is declared as private, where may the variable be accessed?
A private variable may only be accessed within the class in which it is declared.
75. What is an object's lock and which object's have locks?
An object's lock is a mechanism that is used by multiple threads to obtain synchronized access
to the object. A thread may execute a synchronized method of an object only after it has acquired the
object's lock. All objects and classes have locks. A class's lock is acquired on the
class's Class object.
76. What is the Dictionary class?
The Dictionary class provides the capability to store key-value pairs.
77. How are the elements of a BorderLayout organized?
The elements of a BorderLayout are organized at the borders (North, South, East, and West) and the center of a container.
78. What is the % operator?
It is referred to as the modulo or remainder operator. It returns the remainder of dividing the first operand by the second operand.
79. When can an object reference be cast to an interface reference?
An object reference be cast to an interface reference when the object implements the referenced interface.
80. What is the difference between a Window and a Frame?
The Frame class extends Window to define a main application window that can have a menu bar.
81. Which class is extended by all other classes?
The Object class is extended by all other classes.
82. Can an object be garbage collected while it is still reachable?
A reachable object cannot be garbage collected. Only unreachable objects may be garbage collected..
83. Is the ternary operator written x : y ? z or x ? y : z ?
It is written x ? y : z.
84. What is the difference between the Font and FontMetrics classes?
The FontMetrics class is used to define implementation-specific properties, such as ascent and descent, of a Font object.
85. How is rounding performed under integer division?
The fractional part of the result is truncated. This is known as rounding toward zero.
86. What happens when a thread cannot acquire a lock on an object?
If a thread attempts to execute a synchronized method or synchronized statement and is unable to acquire an object's lock, it enters the waiting state until the lock becomes available.
87. What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?
The Reader/Writer class hierarchy is character-oriented, and the InputStream/OutputStream class hierarchy is byte-oriented.
88. What classes of exceptions may be caught by a catch clause?
A catch clause can catch any exception that may be assigned to the Throwable type. This includes the Error and Exception types.
89. If a class is declared without any access modifiers, where may the class be accessed?
A class that is declared without any access modifiers is said to have package access. This means that the class can only be accessed by other classes and interfaces that are defined within the same package.
90. What is the SimpleTimeZone class?
The SimpleTimeZone class provides support for a Gregorian calendar
91. What is the Map interface?
The Map interface replaces the JDK 1.1 Dictionary class and is used associate keys with values.
92. Does a class inherit the constructors of its superclass?
A class does not inherit constructors from any of its superclasses.
93. For which statements does it make sense to use a label?
The only statements for which it makes sense to use a label are those statements that can enclose a break or continue statement.
94. What is the purpose of the System class?
The purpose of the System class is to provide access to system resources.
95. Which TextComponent method is used to set a TextComponent to the read-only state?
setEditable()
96. How are the elements of a CardLayout organized?
The elements of a CardLayout are stacked, one on top of the other, like a deck of cards
97. Is &&= a valid Java operator?
No. It is not a valid java operator.
98. Name the eight primitive Java types.
The eight primitive types are byte, char, short, int, long, float, double, and boolean.
99. Which class should you use to obtain design information about an object?
The Class class is used to obtain information about an object's design.
100. What is the relationship between clipping and repainting?
When a window is repainted by the AWT painting thread, it sets the clipping regions to the area of the window that requires repainting.
Subscribe to:
Posts (Atom)