What is a java bean

Showing Answers 1 - 2 of 2 Answers

Jiri

  • Jul 9th, 2005
 

What is a platform? 
Answer: 
A platform is the hardware or software environment in which a program runs. Most 
platforms can be described as a combination of the operating system and hardware, like Windows 
2000 and XP, Linux, Solaris, and MacOS. 
What is the main difference between Java platform and other platforms? 
Answer: 
The Java platform differs from most other platforms in that it's a software-only platform that 
runs on top of other hardware-based platforms. The Java platform has two components: 1. The Java 
Virtual Machine (Java VM) 2. The Java Application Programming Interface (Java API) 
What is the Java Virtual Machine? 
Answer: 
The Java Virtual Machine is a software that can be ported onto various hardware-based platforms. 
 
What is the Java API? 
Answer: 
The Java API is a large collection of ready-made software components that provide many useful 
capabilities, such as graphical user interface (GUI) widgets 
What is the package? 
Answer: 
The package is a Java namespace or part of Java libraries. The Java API is grouped into 
libraries of related classes and interfaces; these libraries are known as packages. 
What is native code? 
Answer: 
The native code is code that after you compile it, the compiled code runs on a specific 
hardware platform. 
Is Java code slower than native code? Can main() method be overloaded? 
Answer: 
Yes. the main() method is a special method for a program entry. You can overload main() 
method in any ways. But if you change the signature of the main method, the entry point for 
the program will be gone. 
What is the serialization? 
Answer: 
The serialization is a kind of mechanism that makes a class or a bean persistence by having 
its properties or fields and state information saved and restored to and from storage. 
What is a transient variable? 
Answer: 
A transient variable is a variable that may not be serialized. If you don't want some field 
to be serialized, you can mark that field transient or static. 
Which containers use a border layout as their default layout? 
Answer: 
The Window, Frame and Dialog classes use a border layout as their default layout. 
 
Answer: 
Not really. As a platform-independent environment, the Java platform can be a bit slower 
than native code. However, smart compilers, well-tuned interpreters, and just-in-time bytecode 
compilers can bring performance close to that of native code without threatening portability. 
What are three ways in which a thread can enter the waiting state? 
Answer: 
A thread can enter the waiting state by invoking its sleep() method, by blocking on IO, 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. 
Can a lock be acquired on a class? 
Answer: 
Yes, a lock can be acquired on a class. This lock is acquired on the class's Class object. 
What method is used to specify a container's layout? 
Answer: 
The setLayout() method is used to specify a container's layout. 
Which containers use a FlowLayout as their default layout? 
Answer: 
The Panel and Applet classes use the FlowLayout as their default layout. 
Can Java object be locked down for exclusive use by a given thread? 
Answer: 
Yes. You can lock an object by putting it in a "synchronized" block. The locked object is 
inaccessible to any thread other than the one that explicitly claimed it. 
What state does a thread enter when it terminates its processing? 
Answer: 
When a thread terminates its processing, it enters the dead state. 
What is the difference between Process and Thread?(donated in April 2005) 
Answer: 
A process can contain multiple threads. In most multithreading operating systems, a process 
gets its own memory address space; a thread doesn't. Threads typically share the heap belonging 
to their parent process. For instance, a JVM runs in a single process in the host O/S. 
Threads in the JVM share the heap belonging to that process; that's why several threads 
may access the same object.Typically, even though they share a common heap, threads have 
their own stack space. This is how one thread's invocation of a method is kept separate 
from another's.This is all a gross oversimplification, but it's accurate enough at a high level. 
Lots of details differ between operating systems.Process vs. Thread A program Similar to a 
sequential program vs. Can run on its own Cannot run on its own Unit of allocation Unit of 
execution vs. Have its own memory space Share with others Each process has one or more 
threads vs. Each thread belongs to one process Expensive, need to context switch 
vs. Cheap, can use process memory and may not need to context switch More secure. One process 
cannot corrupt another process Less secure.vs. A thread can write the memory used by another 
thread 
If a method is declared as protected, where may the method be accessed? 
Answer: 
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. 
What is the purpose of finalization? 
Answer: 
The purpose of finalization is to give an unreachable object the opportunity to perform any 
cleanup processing before the object is garbage collected. 
Which class is the superclass for every class. 
Answer: 
Object. 
What is the purpose of the finally clause of a try-catch-finally statement? 
Answer: 
The finally clause is used to provide the capability to execute code no matter whether or 
not an exception is thrown or caught. 
What is a static method? 
Answer: 
A static method is a method that belongs to the class rather than any object of the class 
and doesn't apply to an object or even require that any objects of the class have been 
instantiated. 
What is the difference between a Window and a Frame? 
Answer: 
The Frame class extends Window to define a main application window that can have a menu bar. 
 
 
What do heavy weight components mean? 
 
Answer: 
 
Heavy weight components like Abstract Window Toolkit (AWT), depend on the local windowing 
toolkit. For example, java.awt.Button is a heavy weight component, when it is running on the 
Java platform for Unix platform, it maps to a real Motif button. In this relationship, the 
Motif button is called the peer to the java.awt.Button. If you create two Buttons, two peers 
and hence two Motif Buttons are also created. The Java platform communicates with the Motif 
Buttons using the Java Native Interface. For each and every component added to the application, 
there is an additional overhead tied to the local windowing system, which is why these 
components are called heavy weight. 
 
Which package has light weight components? 
 
Answer: 
 
javax.Swing package. All components in Swing, except JApplet, JDialog, JFrame and JWindow are 
lightweight components. 
 
Does a class inherit the constructors of its superclass? 
 
Answer: 
 
A class does not inherit constructors from any of its superclasses. 
 
Name primitive Java types. 
 
Answer: 
 
The primitive types are byte, char, short, int, long, float, double, and boolean. 
 
What restrictions are placed on method overloading? 
 
Answer: 
 
Two methods may not have the same name and argument list but different return types. 
 
What restrictions are placed on method overriding? 
 
Answer: 
 
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. 
 
What is casting? 
 
Answer: 
 
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. 
 
What is the difference between a Scrollbar and a ScrollPane? 
 
Answer: 
 
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. 
 
What is tunnelling? 
 
Answer: 
 
Tunnelling is a route to somewhere. For example, RMI tunnelling is a way to make RMI 
application get through firewall. In CS world, tunnelling means a way to transfer data. 
 
Java Language 
Question: 
 
Does the code in finally block get executed if there is an exception and a return statement 
in a catch block? 
 
Answer: 
 
If an exception occurs and there is a return statement in catch block, the finally block is 
still executed. The finally block will not be executed when the System.exit(1) statement is 
executed earlier or the system shut down earlier or the memory is used up earlier before the 
thread goes to finally block. 
 
What are use cases? 
 
Answer: 
 
A use case describes a situation that a program might encounter and what behavior the program 
should exhibit in that circumstance. It is part of the analysis of a program. The collection of 
use cases should, ideally, anticipate all the standard circumstances and many of the 
extraordinary circumstances possible so that the program will be robust. 
 
What is scalability and performance? 
 
Answer: 
 
Performance is a measure of "how fast can you perform this task." and scalability describes how 
an application behaves as its workload and available computing resources increase. 
 
Java Language 
Question: 
 
What is the benefit of subclass? 
 
Answer: 
 
Generally: 
 
The sub class inherits all the public methods and the implementation. 
The sub class inherits all the protected methods and their implementation. 
The sub class inherits all the default(non-access modifier) methods and their implementation. 
The sub class also inherits all the public, protected and default member variables from the 
super class. 
The constructors are not part of this inheritance model. 
 
In System.out.println(),what is System,out and println,pls explain? 
 
Answer: 
 
System is a predefined final class,out is a PrintStream object acting as a field member and 
println is a built-in overloaded method in the out object. 
 
What is meant by "Abstract Interface"? 
 
Answer: 
 
First, an interface is abstract. That means you cannot have any implementation in an interface. 
All the methods declared in an interface are abstract methods or signatures of the methods. 
 
Why Java does not support pointers? 
 
Answer: 
 
Because pointers are unsafe. Java uses reference types to hide pointers and programmers feel 
easier to deal with reference types without pointers. This is why Java and C-sharp shine. 
 
Can you declare a class as private? (donated in April, 2005) 
 
Answer: 
 
Yes, we can declare a private class as an inner class. For example, 
 
class MyPrivate { 
private static class MyKey { 
String key = "12345"; 

public static void main(String[] args) { 
System.out.println(new MyKey().key);//prints 12345 


 
Can Java code be compiled to machine dependent executable file? 
 
Answer: 
 
Yes. There are many tools out there. If you did so, the generated exe file would be run in the 
specific platform, not cross-platform. 
What are the drawbacks of inheritance? (donated by RS in Mar. 2005) 
 
Answer: 
 
Since inheritance inherits everything from the super class and interface, it may make the 
subclass too clustering and sometimes error-prone when dynamic overriding or dynamic overloading 
in some situation. In addition, the inheritance may make peers hardly understand your code if 
they don't know how your super-class acts. 
 
Usually, when you want to use a functionality of a class, you may use subclass to inherit such 
function or use an instance of this class in your class. Which is better, depends on your 
specification. 
What is a platform? 
Answer: 
A platform is the hardware or software environment in which a program runs. Most 
platforms can be described as a combination of the operating system and hardware, like Windows 
2000 and XP, Linux, Solaris, and MacOS. 
What is the main difference between Java platform and other platforms? 
Answer: 
The Java platform differs from most other platforms in that it's a software-only platform that 
runs on top of other hardware-based platforms. The Java platform has two components: 1. The Java 
Virtual Machine (Java VM) 2. The Java Application Programming Interface (Java API) 
What is the Java Virtual Machine? 
Answer: 
The Java Virtual Machine is a software that can be ported onto various hardware-based platforms. 
 
What is the Java API? 
Answer: 
The Java API is a large collection of ready-made software components that provide many useful 
capabilities, such as graphical user interface (GUI) widgets 
What is the package? 
Answer: 
The package is a Java namespace or part of Java libraries. The Java API is grouped into 
libraries of related classes and interfaces; these libraries are known as packages. 
What is native code? 
Answer: 
The native code is code that after you compile it, the compiled code runs on a specific 
hardware platform. 
Is Java code slower than native code? Can main() method be overloaded? 
Answer: 
Yes. the main() method is a special method for a program entry. You can overload main() 
method in any ways. But if you change the signature of the main method, the entry point for 
the program will be gone. 
What is the serialization? 
Answer: 
The serialization is a kind of mechanism that makes a class or a bean persistence by having 
its properties or fields and state information saved and restored to and from storage. 
What is a transient variable? 
Answer: 
A transient variable is a variable that may not be serialized. If you don't want some field 
to be serialized, you can mark that field transient or static. 
Which containers use a border layout as their default layout? 
Answer: 
The Window, Frame and Dialog classes use a border layout as their default layout. 
 
Answer: 
Not really. As a platform-independent environment, the Java platform can be a bit slower 
than native code. However, smart compilers, well-tuned interpreters, and just-in-time bytecode 
compilers can bring performance close to that of native code without threatening portability. 
What are three ways in which a thread can enter the waiting state? 
Answer: 
A thread can enter the waiting state by invoking its sleep() method, by blocking on IO, 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. 
Can a lock be acquired on a class? 
Answer: 
Yes, a lock can be acquired on a class. This lock is acquired on the class's Class object. 
What method is used to specify a container's layout? 
Answer: 
The setLayout() method is used to specify a container's layout. 
Which containers use a FlowLayout as their default layout? 
Answer: 
The Panel and Applet classes use the FlowLayout as their default layout. 
Can Java object be locked down for exclusive use by a given thread? 
Answer: 
Yes. You can lock an object by putting it in a "synchronized" block. The locked object is 
inaccessible to any thread other than the one that explicitly claimed it. 
What state does a thread enter when it terminates its processing? 
Answer: 
When a thread terminates its processing, it enters the dead state. 
What is the difference between Process and Thread?(donated in April 2005) 
Answer: 
A process can contain multiple threads. In most multithreading operating systems, a process 
gets its own memory address space; a thread doesn't. Threads typically share the heap belonging 
to their parent process. For instance, a JVM runs in a single process in the host O/S. 
Threads in the JVM share the heap belonging to that process; that's why several threads 
may access the same object.Typically, even though they share a common heap, threads have 
their own stack space. This is how one thread's invocation of a method is kept separate 
from another's.This is all a gross oversimplification, but it's accurate enough at a high level. 
Lots of details differ between operating systems.Process vs. Thread A program Similar to a 
sequential program vs. Can run on its own Cannot run on its own Unit of allocation Unit of 
execution vs. Have its own memory space Share with others Each process has one or more 
threads vs. Each thread belongs to one process Expensive, need to context switch 
vs. Cheap, can use process memory and may not need to context switch More secure. One process 
cannot corrupt another process Less secure.vs. A thread can write the memory used by another 
thread 
If a method is declared as protected, where may the method be accessed? 
Answer: 
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. 
What is the purpose of finalization? 
Answer: 
The purpose of finalization is to give an unreachable object the opportunity to perform any 
cleanup processing before the object is garbage collected. 
Which class is the superclass for every class. 
Answer: 
Object. 
What is the purpose of the finally clause of a try-catch-finally statement? 
Answer: 
The finally clause is used to provide the capability to execute code no matter whether or 
not an exception is thrown or caught. 
What is a static method? 
Answer: 
A static method is a method that belongs to the class rather than any object of the class 
and doesn't apply to an object or even require that any objects of the class have been 
instantiated. 
What is the difference between a Window and a Frame? 
Answer: 
The Frame class extends Window to define a main application window that can have a menu bar. 
 
 
What do heavy weight components mean? 
 
Answer: 
 
Heavy weight components like Abstract Window Toolkit (AWT), depend on the local windowing 
toolkit. For example, java.awt.Button is a heavy weight component, when it is running on the 
Java platform for Unix platform, it maps to a real Motif button. In this relationship, the 
Motif button is called the peer to the java.awt.Button. If you create two Buttons, two peers 
and hence two Motif Buttons are also created. The Java platform communicates with the Motif 
Buttons using the Java Native Interface. For each and every component added to the application, 
there is an additional overhead tied to the local windowing system, which is why these 
components are called heavy weight. 
 
Which package has light weight components? 
 
Answer: 
 
javax.Swing package. All components in Swing, except JApplet, JDialog, JFrame and JWindow are 
lightweight components. 
 
Does a class inherit the constructors of its superclass? 
 
Answer: 
 
A class does not inherit constructors from any of its superclasses. 
 
Name primitive Java types. 
 
Answer: 
 
The primitive types are byte, char, short, int, long, float, double, and boolean. 
 
What restrictions are placed on method overloading? 
 
Answer: 
 
Two methods may not have the same name and argument list but different return types. 
 
What restrictions are placed on method overriding? 
 
Answer: 
 
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. 
 
What is casting? 
 
Answer: 
 
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. 
 
What is the difference between a Scrollbar and a ScrollPane? 
 
Answer: 
 
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. 
 
What is tunnelling? 
 
Answer: 
 
Tunnelling is a route to somewhere. For example, RMI tunnelling is a way to make RMI 
application get through firewall. In CS world, tunnelling means a way to transfer data. 
 
Java Language 
Question: 
 
Does the code in finally block get executed if there is an exception and a return statement 
in a catch block? 
 
Answer: 
 
If an exception occurs and there is a return statement in catch block, the finally block is 
still executed. The finally block will not be executed when the System.exit(1) statement is 
executed earlier or the system shut down earlier or the memory is used up earlier before the 
thread goes to finally block. 
 
What are use cases? 
 
Answer: 
 
A use case describes a situation that a program might encounter and what behavior the program 
should exhibit in that circumstance. It is part of the analysis of a program. The collection of 
use cases should, ideally, anticipate all the standard circumstances and many of the 
extraordinary circumstances possible so that the program will be robust. 
 
What is scalability and performance? 
 
Answer: 
 
Performance is a measure of "how fast can you perform this task." and scalability describes how 
an application behaves as its workload and available computing resources increase. 
 
Java Language 
Question: 
 
What is the benefit of subclass? 
 
Answer: 
 
Generally: 
 
The sub class inherits all the public methods and the implementation. 
The sub class inherits all the protected methods and their implementation. 
The sub class inherits all the default(non-access modifier) methods and their implementation. 
The sub class also inherits all the public, protected and default member variables from the 
super class. 
The constructors are not part of this inheritance model. 
 
In System.out.println(),what is System,out and println,pls explain? 
 
Answer: 
 
System is a predefined final class,out is a PrintStream object acting as a field member and 
println is a built-in overloaded method in the out object. 
 
What is meant by "Abstract Interface"? 
 
Answer: 
 
First, an interface is abstract. That means you cannot have any implementation in an interface. 
All the methods declared in an interface are abstract methods or signatures of the methods. 
 
Why Java does not support pointers? 
 
Answer: 
 
Because pointers are unsafe. Java uses reference types to hide pointers and programmers feel 
easier to deal with reference types without pointers. This is why Java and C-sharp shine. 
 
Can you declare a class as private? (donated in April, 2005) 
 
Answer: 
 
Yes, we can declare a private class as an inner class. For example, 
 
class MyPrivate { 
private static class MyKey { 
String key = "12345"; 

public static void main(String[] args) { 
System.out.println(new MyKey().key);//prints 12345 


 
Can Java code be compiled to machine dependent executable file? 
 
Answer: 
 
Yes. There are many tools out there. If you did so, the generated exe file would be run in the 
specific platform, not cross-platform. 
What are the drawbacks of inheritance? (donated by RS in Mar. 2005) 
 
Answer: 
 
Since inheritance inherits everything from the super class and interface, it may make the 
subclass too clustering and sometimes error-prone when dynamic overriding or dynamic overloading 
in some situation. In addition, the inheritance may make peers hardly understand your code if 
they don't know how your super-class acts. 
 
Usually, when you want to use a functionality of a class, you may use subclass to inherit such 
function or use an instance of this class in your class. Which is better, depends on your 
specification. 

  Was this answer useful?  Yes

Sumit Kumar

  • Aug 30th, 2005
 

A Java Bean is a reusable software component that can be visually manipulated in builder tools.  
To understand the precise meaning of this definition of a Bean, clarification is required for the following terms:  
 
1. Software component: 
Reusable software components are designed to apply the power and benefit of reusable, interchangeable parts from other industries to the field of software construction. Other industries have long profited from reusable components. Reusable electronic components are found on circuit boards. A typical part in your car can be replaced by a component made from one of many different competing manufactures. Lucrative industries are built around parts construction and supply in most competitive fields. The idea is that standard interfaces allow for interchangeable, reusable components.  
For example: Reusable software components can be simple like familiar push buttons, text fields list boxes, scrollbars, dialogs, and etc. 
 
2. Builder tool: 
The primary purpose of beans is to enable the visual construction of applications. You've probably used or seen applications like Visual Basic, Visual Age, or Delphi. These tools are referred to as visual application builders, or builder tools for short.  
Typically such tools are GUI applications, although they need not be. There is usually a palette of components available from which a program designer can drag items and place them on a form or client window.  
 
3. Visual manipulation: 
Individual Java Beans will vary in functionality, but most share certain common defining features.  
 Support for introspection allowing a builder tool to analyze how a bean works. 
 Support for customization allowing a user to alter the appearance and behavior of a bean.  
 Support for events allowing beans to fire events, and informing builder tools about both the events they can fire and the events they can handle.  
 Support for properties allowing beans to be manipulated programmatically, as well as to support the customization mentioned above.  
 Support for persistence allowing beans that have been customized in an application builder to have their state saved and restored. Typically persistence is used with an application builder's save and load menu commands to restore any work that has gone into constructing an application. 
While Beans are intended to be used primarily with builder tools, they need not be. Beans can be manually manipulated by text tools through programmatic interfaces. All key APIs, including support for events, properties, and persistence, have been designed to be easily read and understood by human programmers as well as by builder tools. 

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions