2. Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt .
Ltd
5. Muhammed Noufal V T
muhammednoufalvt@gmail.c
om
www.facebook.com/vtnoufa
lvt
twitter.com/noufalurnappy
in.linkedin.com/pub/muham
med-noufal
9744003056
6. What is Java Bean
• It is a reusable Software component.
• A bean encapsulate many object into
one object.
• We can access this object from
multiple places.
• It provides easy maintenance.
• It provide methods to set and get the
values of the properties, known as
getter and setter methods.
11. Setting values for it’s
properties
import com.baabte.exambean;
import java.util.ArrayList;
public class ques {
ArrayList <exambean> ques = new ArrayList<exambean>();
Public int questn(){
exambean qs1 = new exambean();
qs1.setQuestion("1. Who give music to the song Sare jahan se acha..?");
qs1.setA("A.Pandit Ravi Shankar");
qs1.setB("B.Subha lakshmi");
qs1.setC("C.AR Rahman");
qs1.setD("D.Muhammad Iqbal");
qs1.setAnswer("A");
ques.add(qs1);
}
12. Getting values for it’s properties
public static void main(String[] args) {
int count=0;
boolean flag=false;
ques quesObj = new ques();
ArrayList newList = quesObj.getList();
int size = newList.size();
for(int i=0;i<size;i++)
{
do
{
else if(!answer.matches("A") && !answer.matches("B")
&& !answer.matches("C") && !answer.matches("D")
)
{flag=true;
System.out.println("Invalid Entry");
flag=false;
exambean beanObj=(exambean) newList.get(i);
System.out.println(beanObj.getQuestion());
System.out.println(beanObj.getA());
System.out.println(beanObj.getB());
System.out.println(beanObj.getC());
System.out.println(beanObj.getD());
System.out.println("Pleas Enter Your Answer: ");
Scanner ans = new Scanner(System.in);
String answer= ans.nextLine().toUpperCase();
if(answer.matches(beanObj.getAnswer())){
count++;
}
}
}
}
}
while(flag);}
System.out.println("Total Score= "+count);
13. Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Notas del editor
Open EmployeeBean.java fileRight click inside the file select Source->Generate Getters and Setters