Important Web Design and Development Short Questions
Chapter: 36
Question 1:
Describe the design conventions of a JavaBean.
Answer:
A JavaBean must have a zero-argument constructor, no public instance variables, private attributes accessed through getters and setters, and must be serializable.
Chapter: 36
Question 2:
What is the function of retrieveCourseList() method in CourseDAO?
Answer:
The retrieveCourseList() method queries the database for course details based on the course name and returns an ArrayList of CourseOutlineBean objects containing session numbers, topics, and assignments.
Chapter: 36
Question 3:
How does web.jsp display course outlines?
Answer:
web.jsp creates a CourseDAO object, calls retrieveCourseList("web") to get course details, and iterates over the resulting ArrayList to display session numbers, topics, and assignments in a tabular format.
Chapter: 36
Question 4:
What does the CourseOutlineBean class represent?
Answer:
The CourseOutlineBean class represents a single row of the course outline table, including attributes like sessionNo, topic, and assignment. It follows JavaBean conventions with getters and setters for these attributes.
Chapter: 36
Question 5:
How are web.jsp and java.jsp similar in their implementation?
Answer:
Both web.jsp and java.jsp use similar structures: they create a CourseDAO object, call retrieveCourseList() with different course names, and display the results in a tabular format using a loop to iterate over CourseOutlineBean objects.
Chapter: 36
Question 6:
Why is JavaBeans technology used in the example?
Answer:
JavaBeans technology is used to separate concerns by encapsulating database connectivity and business logic into beans, making the JSP pages less cluttered and easier to maintain.
Chapter: 36
Question 7:
What is the primary benefit of using JavaBeans in the provided example?
Answer:
The primary benefit is improved code organization and maintenance. By separating database logic and business logic into JavaBeans, the JSP pages focus solely on presentation, reducing clutter and making it easier to update or modify the application.
Chapter: 36
Question 8:
What does the CourseOutlineBean class not include in its design?
Answer:
The CourseOutlineBean class does not include public instance variables. Instead, it adheres to JavaBean conventions by using private fields with public getter and setter methods.
Chapter: 37
Question 9:
What is the purpose of the <jsp:useBean /> action element?
Answer:
The <jsp:useBean /> action element is used to obtain a reference to an existing JavaBean object. If the object does not exist, it will be instantiated. It requires specifying the id of the bean, the scope (page, request, session, or application), and the class of the bean.
Chapter: 37
Question 10:
How does the <jsp:setProperty /> action element work?
Answer:
The <jsp:setProperty /> action element sets or changes the value of a specified property in a JavaBean. It uses the name attribute to match the bean's id, the property attribute to specify which property to change, and the value attribute to provide the new value. String values are automatically converted to the appropriate type.