Java Beans are reusable software components that can be manipulated visually in an IDE. A Java Bean must have a no-argument constructor, implement accessor methods for properties rather than using public fields, and allow for introspection. Introspection allows tools to analyze a bean's capabilities through naming conventions or an additional class. Properties, events, and methods follow common design patterns to identify their signatures and behaviors. Persistence allows a bean's configuration to be saved and restored by serializing the object.
Introduction to java beans, java beans, Core java, j2se, getting started with java beans programming, java to standard edition, beans in java, beans programming in java
Introduction to java beans, java beans, Core java, j2se, getting started with java beans programming, java to standard edition, beans in java, beans programming in java
JSP technology has facilitated the segregation of the work of a Web designer and a Web developer.
A Web designer can design and formulate the layout for the Web page by using HTML.
On the other hand, a Web developer working independently can use java code and other JSP specific tags to code the business logic.
The simultaneous construction of the static and dynamic content facilitates development of quality applications with increased productivity.
This presentation gives introduction to ADO.Net.
Basic introduction to connected & Disconnected architecture.
and explain the each every component in Ado.net
What is the DOM?
The DOM is a W3C (World Wide Web Consortium) standard.
The DOM defines a standard for accessing documents:
"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."
The W3C DOM standard is separated into 3 different parts:
Core DOM - standard model for all document types
XML DOM - standard model for XML documents
HTML DOM - standard model for HTML documents
The HTML DOM (Document Object Model)
When a web page is loaded, the browser creates a Document Object Model of the page.
The HTML DOM model is constructed as a tree of Objects.
With the HTML DOM, JavaScript can access and change all the elements of an HTML document.
JSP technology has facilitated the segregation of the work of a Web designer and a Web developer.
A Web designer can design and formulate the layout for the Web page by using HTML.
On the other hand, a Web developer working independently can use java code and other JSP specific tags to code the business logic.
The simultaneous construction of the static and dynamic content facilitates development of quality applications with increased productivity.
This presentation gives introduction to ADO.Net.
Basic introduction to connected & Disconnected architecture.
and explain the each every component in Ado.net
What is the DOM?
The DOM is a W3C (World Wide Web Consortium) standard.
The DOM defines a standard for accessing documents:
"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."
The W3C DOM standard is separated into 3 different parts:
Core DOM - standard model for all document types
XML DOM - standard model for XML documents
HTML DOM - standard model for HTML documents
The HTML DOM (Document Object Model)
When a web page is loaded, the browser creates a Document Object Model of the page.
The HTML DOM model is constructed as a tree of Objects.
With the HTML DOM, JavaScript can access and change all the elements of an HTML document.
1.what is the difference between a instance variable and an local va.pdfarchgeetsenterprises
1.what is the difference between a instance variable and an local variable.Explain clearly and
give an example.
2.what is the difference between call-by-vale and call by-reference when working with java
methods? explain clearly and given an example.
Solution
1)
Instance variables:
Instance variables area the variables whose new copy will be created when ever an object is
created.
They will be used to hold the data of an object.They can be accessible everywhere with in the
class.
For every new Object creation a new copy of instance variables will get created.
Rectangle.java
public class Rectangle {
private double length;
private double width;
public Rectangle(double length, double width) {
super();
this.length = length;
this.width = width;
}
public double getLength() {
return length;
}
public void setLength(double length) {
this.length = length;
}
public double getWidth() {
return width;
}
public void setWidth(double width) {
this.width = width;
}
public double calArea()
{
return getLength()*getWidth();
}
}
______________________________
TestClass.java
public class TestClass {
public static void main(String[] args) {
Rectangle rect1 =new Rectangle(9,10);
System.out.println(\"Area of the Rectangle#1 :\"+rect1.calArea());
Rectangle rect2 =new Rectangle(11,13);
System.out.println(\"Area of the Rectangle#2:\"+rect2.calArea());
}
}
_________________________________
output:
Area of the Rectangle#1 :90.0
Area of the Rectangle#2:143.0
_______________________________
Here in the above example Rectangle class contains length and width as instance variables.
When ever we created object for the Rectangle class a new copy of instance variables will be
created.
Rectangle rect1 =new Rectangle(9,10);
When the above statement is executed a Rectangle object will be created ,when ever Rectangle
object is created new copy of instance variables will be created which holds length=9 and
width=10 inside it.
Rectangle rect2 =new Rectangle(11,13);
When the above statement is executed another Rectangle object will be created ,when ever
Rectangle object is created again new copy of instance variables will be created which holds
length=11 and width=13 inside it.
Here first Rectangle object instance variable will not get overridden by the second Rectangle
object instance variables.Because those instance variables will stored inside each object
seperately in different memory locations.
When coming to the local variables.These are the variables which are declaredlocally inside the
method.Their scope is limited only to the method itself.If we have a local variables which is of
same name as the instance variable and if we are accessing the the variiable then priority will be
given to the local variables than instance variables.These local variables cannot be accessed be
other method of that obejct.Their scope is limited only to the method i which they heve been
declared.
Square.java
public class Square {
private double side;
public Square(double side) {
super();
this.side = si.
The Elphinstonian 1988-College Building Centenary Number (2).pdfMukesh Tekwani
This is the 1988 issue of The Elphinstonian, the annual magazine of Elphinstone College, Mumbai. This is the special issue to commemorate the Century of the Elphinstone College Building in Mumbai.
What is gravitation, Newton's law of gravitation, projection of a satellite, derivations, weightlessness explained, change in value of g with altitude, time period of a satellite, binding energy, escape velocity of a satellite,
ISCE-Class 12-Question Bank - Electrostatics - PhysicsMukesh Tekwani
This is a 14 page question bank on the chapters of Electrostatics. This is based on the syllabus of most Board exams such as CBSE, ISCE and state boards.
Extremely important topic for Digital electronics, digital circuits, computer architecture and computer science.
Full video is available on Youtube: https://youtu.be/oyOaXqx06pY
This video explains the method of converting a decimal number to a binary number. Many solved examples are given here and also two exercises which you can attempt on your own and then check the answers.
I have also discussed the concept of LSB (least significant bit) and MSB (most significant bit), and also least significant digit (LSD) and most significant digit (MSD).
This topic is important for following courses: class 11 and 12 computer science of all state boards, class 11 and 12 physics, BSc Computer science, BSc IT, MCA (Masters degree in Computer Applications), BTech, BE (First Year), and many competitive examinations.
Free Lectures on YouTube for IGCSE Physics for the syllabus effective 2020-21. These lectures cover the syllabus of IGCSE and a major part of GCSE syllabus also.
1. The Hidden Meaning of Words in Science Question Papers
2. Scientific Notation or Powers of Ten Notation
3. Units and Base Quantities
4. What is Physics?
What is Cyber Law? Why is cyber security law needed? International cyber law. What is copyright? What are security, controls, privacy, piracy and ethics? Code of ethics for computer professionals. What is cyber insurance?
The Metaverse and AI: how can decision-makers harness the Metaverse for their...Jen Stirrup
The Metaverse is popularized in science fiction, and now it is becoming closer to being a part of our daily lives through the use of social media and shopping companies. How can businesses survive in a world where Artificial Intelligence is becoming the present as well as the future of technology, and how does the Metaverse fit into business strategy when futurist ideas are developing into reality at accelerated rates? How do we do this when our data isn't up to scratch? How can we move towards success with our data so we are set up for the Metaverse when it arrives?
How can you help your company evolve, adapt, and succeed using Artificial Intelligence and the Metaverse to stay ahead of the competition? What are the potential issues, complications, and benefits that these technologies could bring to us and our organizations? In this session, Jen Stirrup will explain how to start thinking about these technologies as an organisation.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionAggregage
Join Maher Hanafi, VP of Engineering at Betterworks, in this new session where he'll share a practical framework to transform Gen AI prototypes into impactful products! He'll delve into the complexities of data collection and management, model selection and optimization, and ensuring security, scalability, and responsible use.
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
Climate Impact of Software Testing at Nordic Testing DaysKari Kakkonen
My slides at Nordic Testing Days 6.6.2024
Climate impact / sustainability of software testing discussed on the talk. ICT and testing must carry their part of global responsibility to help with the climat warming. We can minimize the carbon footprint but we can also have a carbon handprint, a positive impact on the climate. Quality characteristics can be added with sustainability, and then measured continuously. Test environments can be used less, and in smaller scale and on demand. Test techniques can be used in optimizing or minimizing number of tests. Test automation can be used to speed up testing.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
In his public lecture, Christian Timmerer provides insights into the fascinating history of video streaming, starting from its humble beginnings before YouTube to the groundbreaking technologies that now dominate platforms like Netflix and ORF ON. Timmerer also presents provocative contributions of his own that have significantly influenced the industry. He concludes by looking at future challenges and invites the audience to join in a discussion.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
In this presentation, we examine the challenges and limitations of relying too heavily on PHP frameworks in web development. We discuss the history of PHP and its frameworks to understand how this dependence has evolved. The focus will be on providing concrete tips and strategies to reduce reliance on these frameworks, based on real-world examples and practical considerations. The goal is to equip developers with the skills and knowledge to create more flexible and future-proof web applications. We'll explore the importance of maintaining autonomy in a rapidly changing tech landscape and how to make informed decisions in PHP development.
This talk is aimed at encouraging a more independent approach to using PHP frameworks, moving towards a more flexible and future-proof approach to PHP development.
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Java beans
1. Java Beans
JAVA BEANS
What are Java Beans?
1. A Java Bean is a software component that is designed to be reusable.
2. It is a java class that has a zero-argument (empty) constructor. So we can either not specify a
constructor at all, or define a constructor with no arguments.
3. JavaBean class has no public instance variables (fields). Therefore we have to use the accessor
methods instead of allowing direct access to the private fields.
4. Values are accessed through methods called as getXXX and setXXX. If a class has a method getTitle
that returns a string, the class is said to have a String property named Title.
5.
6. A bean may perform a simple function, such as checking the spelling of a document, or a complex
function, such as forecasting the performance of a stock portfolio.
7. A Bean may be visible to an end user, e.g., a button on a graphical user interface. A Bean may also be
invisible to a user, e.g., software to decode a stream of multimedia information in real time.
8. A Bean may be designed to work autonomously on a user’s workstation or to work in cooperation
with a set of other distributed components. E.g., software to generate a pie chart from a set of data
points is an example of a Bean that can execute locally. However, a Bean that provides real-time price
information from a stock will have to work in cooperation with other distributed software to obtain its
data.
What are the advantages of using Java beans?
1. A Bean has all the benefits of Java’s “write-once, run-anywhere” paradigm.
2. We can control which properties, events, and methods of a Bean are available to an application
builder.
3. A Bean may be designed to operate correctly in different locales (environments), and are therefore
useful in global markets.
4. Auxiliary software can be provided to help a person configure a Bean. This software is only needed
when the design-time parameters for that component are being set. It does not need to be included in
the run-time environment.
5. The configuration settings of a Bean can be saved in persistent storage and restored at a later time.
6. A Bean may register to receive events from other objects and can generate events that are sent to other
objects.
Explain the term “introspection” in the context of Java Beans.
1. Introspection is the process of analyzing a Bean to determine its capabilities. This is an important
feature of the Java Beans API, because it allows an application builder tool to obtain information
about a component.
2. There are two ways in which the developer of a Bean can indicate which of its properties, events, and
methods should be exposed by an application builder tool.
3. In the first method, simple naming conventions are used. These allow the introspection mechanisms to
infer information about a Bean.
4. In the second way, an additional class is provided that explicitly supplies this information.
5. Design Pattern for Properties:
a. A design pattern specifies the rules for forming the method signature, return type and even its
name. Design patterns can provide a useful documentation hint for programmers.
b. The major design patterns are:
i. Property design pattern,
ii. Event design pattern, and
iii. Method design pattern
Prof. Mukesh N. Tekwani Page 1 of 8
2. Java Beans
c. A property is a named attribute. It specifies the characteristic, behavior and state of the object.
Properties are functions which can get or set the values of a variable. A property is a subset of
a Bean’s state. The values assigned to the properties determine the behavior and appearance
of the component.
d. Property design patterns are used to identify the publicly accessible properties of a bean.
e. The setter method is used to set a property and the getter method is used to obtain the
property.
f. If a property has only a getter method, JavaBeans assumes that it is a read-only property. If
both getter and setter methods are defined, JavaBeans assumes it is a read-write property.
g. There are three types of properties: simple, Boolean and indexed.
h. Simple Properties:
A simple property has a single value. The following design pattern is used:
public T getN()
public void setN(T arg)
Here N is the name of the property and T is its type.
A read/write property has both these methods to access its value. A read-only property has
only the get method. The write-only property has only the set method.
Example:
}
private double depth, height, width;
public double setDepth(double d)
public double getDepth() {
{ depth = d;
return depth; }
public double getHeight() public double getWidth()
{ {
return height; return width;
} }
public double setHeightdouble h) public double setWidth(double w)
{ {
height = h; width = w;
} }
i. Boolean Properties:
The design pattern is as follows:
public Boolean isN( );
public void setN(Boolean a);
j. Indexed Properties:
An indexed property consists of multiple values, i.e,, it is an array of simple properties. It has
the following design pattern:
public T getN (int index);
public void setN (int index, T value);
public T [ ] getN ();
public void setN (T values[]);
Consider an indexed property data. Its getter and setter methods are shown below:
private double data [ ];
Page 2 of 8 mukeshtekwani@hotmail.com
3. Java Beans
public double getData(int index) public double [ ] getData()
{ {
return data[index]; return data;
} }
public void setData(int index double
value) public void setData(double [ ]
{ values)
data [index] = value; {
} data = new double[values.length];
System.arraycopy(values, 0, data, 0,
values.length);
}
6. Design Pattern for Events:
When a Bean’s internal state changes, it is often necessary to inform the other object of the change.
Beans can do this by communicating events with other objects.
Beans send event notifications to event listeners that have registered themselves with a bean. Beans
use the delegation event model. An event is generated by the bean and sent to other objects.
public void addTListener(TListener eventListener);
public void removeTListener(TListener eventListener);
These methods are used to add or remove a listener for the specified event.
For example, to add support for event listener that implements the ActionListener interface, we write:
public void addActionListener(ActionListener al);
public void removeActionListener(ActionListener al);
TheActionListener interface is used to receive actions like mouse clicks.
7. Constrained Bean Property:
A Bean property is constrained when any change to that property can be prevented. The Bean can
itself prevent a property change.
The 3 parts of a constrained property implementation are:
• A source bean containing constrained properties.
• Listener object that can accept or reject proposed chages to the constrained property in the
source bean.
• A PropertyChangeEvent object containing the property name, its old value and new values.
8. Bound Bean Property:
A Bean that has a bound property generates an event when the property is changed. The event is of the
type PropertyChangeEvent and it is sent to the objects that have registered for this event notification.
What is Persistence in the context of JavaBeans?
Persistence is the ability to save a Bean to nonvolatile storage (disk) and retrieve it at a later time.
Configuration settings are important and are saved this way.
Prof. Mukesh N. Tekwani Page 3 of 8
4. Java Beans
Java class libraries have object serialization capabilities. Serialization is the process of writing the state of
an object to a byte stream (file). A Bean must implement the java.io.Serializable interface. This makes
serialization automatic.
Write short note on JAR files? What are the options available with JAR file?
1. JAR – Java Archive
2. A Jar file has the extension .jar.
3. It is a compressed file that contains classes and other resources which are required to use beans. The
Jar files can contain videos files, image files, audio files, etc.,
4. BDK expect Beans to be packaged within JAR files.
5. A JAR file allows you to efficiently deploy a set of classes and their associated resources. For
example, a developer may build a multimedia application that uses various sound and image files. A
set of Beans can control how and when this information is presented. All of these pieces can be placed
into one JAR file.
6. The elements in a JAR file are compressed and so downloading a JAR file is faster than downloading
several uncompressed files.
7. Digital signatures can also be associated with the individual elements in a JAR file. This allows a
consumer to be sure that these elements were produced by a specific organization or individual.
The jar utility is : jar options file
Example: Create a JAR file named XYZ.Jar that contains all the .class and .gif files in the current
directory.
jar cf Xyz.jar *.class *.gif
Options available with jar:
Option Description
c A new archive is to be created.
C Change directories during command execution.
f The first element in the file list is the name of the
archive that is to be created or accessed.
i Index information should be provided.
m The second element in the file list is the name of the
external manifest file.
M Manifest file not created.
t The archive contents should be tabulated.
u Update existing JAR file.
v Verbose output should be provided by the utility as it
executes.
x Files are to be extracted from the archive.
0 Do not use compression.
Examples:
Tabulating the Contents of a jar file:
jar tf Xyz.jar
Extracting files from a jar file:
jar xf Xyz.jar
Page 4 of 8 mukeshtekwani@hotmail.com
5. Java Beans
Updating an existing jar file:
jar –uf Xyz.jar file1.class
What is the manifest file?
1. A manifest file is a text file which contains the descriptions of the beans contained in the JAR files.
2. A manifest file indicates which of the components in a JAR file are Java Beans. An example of a
manifest file is this: The JAR file contains four .gif files and one .class file. The last entry is a Bean.
Name: slide0.gif
Name: slide1.gif
Name: slide2.gif
Name: slide3.gif
Name: Slides.class
Java-Bean: True
3. A manifest file may reference many.class files. If a .class file is a Java Bean, its entry must be
immediately followed by the line “Java-Bean: True”.
Explain the BeanInfo interface.
1. There are two ways to determine what information is available to the user of a Bean.
2. One way is through the design patterns. The design pattern implicitly determines what properties
are available to the user.
3. The other way is by using the BeanInfo interface.
4. The BeanInfo interface allows the programmer to explicitly control what information is available.
5. The methods of BeanINfo interface are:
PropertyDescriptor [] getPropertyDescriptors()
EventSetDescriptor [] getEventSetyDescriptors()
MethodDescriptor [] getMethodDescriptors()
6. All these methods return an array of objects that provide information about properties, events and
methods of a Bean.
7. The classes PropertyDescriptor, EventSetDescriptor, and MethodDescriptor are defined in the
java.beans package.
8. When creating a class that implements BeamInfo, we must give it the name bnameBeamInfo,
where bname is the name of the Bean. E.g., MyBeanBeanInfo.
Discuss the following classes of JavaBeans API: Introspector, PropertyDescriptor,
EventSetDescriptor, and MethodDescriptor
Introspector Class: This class provides methods that support introspection. The most important one is
the getBeanInfo() method. This method returns a BeanInfo object that can be used to obtain information
about the Bean.
PropertyDescriptor Class: This class describes the Bean properties. It has many methods that can
manage and describe properties. E.g., we can determine if a property is bound by calling the isBound()
method. Similarly there is a method isConstrained(). To get the name of the property we use the
getName() method.
EventSetDescriptor: This class represents a Bean event. Methods of this class are:
getAddListenerMethod() – this is used to obtain the methods used to add listeners; the
getRemoveListenerMethod() is used to obtain methods used to remove listeners.
Prof. Mukesh N. Tekwani Page 5 of 8
6. Java Beans
MethodDescriptor: This class represents a Bean method. We can use the method getName() to obtain the
name of a method.
PROGRAMS
1. Write JavaBean program that finds square and cube value in terms of properties.
public class mathcalc
{
int a;
public mathcalc() { }
public void setA(int m)
{
a = m;
}
public int getA()
{
return (a);
}
public int getSquare()
{
return (a * a);
}
public void setSquare( int m) { }
public int getCube()
{
return (a * a * a);
}
public void setCube( int m) { }
2. Write JavaBean program to find the sum, difference, product and ratio of two numbers as
properties.
public class cal public void setA(int m)
{ {
int a, b; a = m;
}
public cal()
{ public int getB()
a = 0; b = 1; {
} return b;
}
public int getA()
{ public void setB(int n)
return a; {
} b = n;
}
Page 6 of 8 mukeshtekwani@hotmail.com
7. Java Beans
public int getAdd() public int getMul()
{ {
return (a + b); return (a * b);
} }
public void setAdd(int m){ } public void setMul(int m) { }
public int getSub() public int getDiv()
{ {
return (a - b); return (a / b);
} }
public void setSub(int m) { } public void setDiv(int m) { }
3. Write JavaBean program to find the reverse of a number as a property.
public class revno
{
int n;
public revno() {}
public int getN()
{
return n;
}
public void setN(int m)
{
n = m;
}
public int getRevNo()
{
int d, revnum = 0;
int temp = n;
while (temp > 0)
{
d = temp % 10;
revnum = (revnum * 10) + d;
temp = temp / 10;
}
return revnum;
}
public void setRevNum(int m){}
}
Prof. Mukesh N. Tekwani Page 7 of 8
8. Java Beans
4. Write multiline JavaBean program.
In this program we use TextArea for multiline text.
import java.awt.*;
import java.awt.event.*;
public class multiline extends Panel
{
int height, width;
TextArea ta;
public multiline()
{
TextArea ta = new TextArea(5, 50);
add(ta);
ta.setText(“Learning Java Beans” +
“n From Internet resources” +
“n and books”);
setSize(300, 300);
setVisible(true);
}
public int getheight()
{
return height;
}
public void setheight(int h)
{
height = h;
setSize(width, height);
}
public int getwidth()
{
return width;
}
public void setwidth(int w)
{
width = w;
setSize(width, height);
}
}
Page 8 of 8 mukeshtekwani@hotmail.com