What is java bean? What are the necessary criteria of bean class? How many types of properties are in java bean?
What is java bean? What are the necessary criteria of bean class? How many types of properties are in java bean?
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
What is java bean? What are the necessary criteria of bean class? How many types of properties are in java bean? Discuss about them.
Expert Solution
Step 1
Any Normal Java class needs to follow some constraint to become a Java Bean class.
These constraints are: -
RULE 1: All data members defined in class must be private and can only be accessed or modified using getter and setter method.
- These data members can only accessed or modified using methods provided by the Class.
- The name of methods for accessing the values are getters and method which allow modifications in private data members of class are called setters.
- The setter and getter method name must be followed by data member also called properties of class.
- Example: if data member is name.
- Then setter method name is setName, while the getter method name is getName().
- Any random name can't be used for accessing or modifying those fields.
RULE 2: - The class must have a default constructor also 0-argument constructor.
- For every class in java the compiler provides one default constructor if any constructor is not explicitly defined in the class. This constructor is called no-arg constructor.
- It is must to have a default constructor (no-arg constructor) in the class either define explicitly or use the default constructor given by compiler.
RULE 3: - This class must implement the Serializable interface.
- Serializable interface is used to store the objects, send them over the network or save it in disk or use the object in other processes.
- Serializable interface does not have any method, It is mainly used a tagging or Marker interface.
- Tagging interface means if the class implements the serializable interface the objects of the class can be stored, sent over the network or use in other processes as per requirement.
Step by step
Solved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education