એડવાન્સ જાવા પ્રોગ્રામિંગ (4351603) - ઉનાળા 2024 સોલ્યુશન
એડવાન્સ જાવા પ્રોગ્રામિંગ (4351603) ઉનાળા 2024 પરીક્ષા માટે સોલ્યુશન ગાઇડ
પ્રશ્ન 1(અ) [3 ગુણ]
AWT અને Swing વચ્ચેનો તફાવત સમજાવો.
જવાબ:
| લક્ષણ | AWT | Swing |
|---|---|---|
| Platform | Platform dependent | Platform independent |
| Components | Heavy weight | Light weight |
| Look & Feel | Native OS look | Pluggable look & feel |
| Performance | ઝડપી | AWT કરતાં ધીમું |
મુખ્ય મુદ્દાઓ:
- Heavy vs Light: AWT native OS components વાપરે છે, Swing pure Java વાપરે છે
- દેખાવ: AWT OS style અનુસરે છે, Swing બધા platforms પર સમાન look આપે છે
- સુવિધાઓ: Swing વધુ advanced components જેમ કે JTable, JTree પ્રદાન કરે છે
મેમરી ટ્રીક: "Swing Provides Lightweight Components"
પ્રશ્ન 1(બ) [4 ગુણ]
Mouse Motion Listener ને ઉદાહરણ સાથે સમજાવો.
જવાબ:
MouseMotionListener interface Java Swing applications માં mouse movement events ને handle કરે છે.
કોષ્ટક: Mouse Motion Events
| Method | હેતુ |
|---|---|
| mouseDragged() | જ્યારે mouse drag થાય ત્યારે call થાય |
| mouseMoved() | જ્યારે mouse ખસે ત્યારે call થાય |
કોડ ઉદાહરણ:
Java
મેમરી ટ્રીક: "Mouse Motion Makes Dynamic"
પ્રશ્ન 1(ક) [7 ગુણ]
યુનિવર્સિટી સાથે જોડાયેલા વિવિધ અભ્યાસક્રમો માટે checkboxes બનાવવા માટે એક પ્રોગ્રામ ડેવલપ કરો જેથી પસંદ કરેલ કોર્સ પ્રદર્શિત થાય.
જવાબ:
Java
મુખ્ય લક્ષણો:
- ItemListener: checkbox state changes ને detect કરે છે
- Dynamic Display: real-time માં પસંદ કરેલા કોર્સ update કરે છે
- Multiple Selection: એકથી વધુ કોર્સ પસંદ કરવાની મંજૂરી આપે છે
મેમરી ટ્રીક: "Check Items Listen Dynamically"
પ્રશ્ન 1(ક) અથવા [7 ગુણ]
Swing components નો ઉપયોગ કરીને (JFrame, JRadioButton, ItemListener વગેરેનો ઉપયોગ કરીને) Traffic signal (લાલ, લીલો અને પીળો) implement કરવા માટે એક પ્રોગ્રામ વિકસાવો.
જવાબ:
Java
આકૃતિ:
goat
મેમરી ટ્રીક: "Radio Buttons Paint Graphics"
પ્રશ્ન 2(અ) [3 ગુણ]
JDBC Type-4 driver સમજાવો.
જવાબ:
JDBC Type-4 Driver (Native Protocol Driver)
| લક્ષણ | વર્ણન |
|---|---|
| પ્રકાર | Pure Java driver |
| Communication | Direct database protocol |
| Platform | Platform independent |
| Performance | સર્વોચ્ચ પ્રદર્શન |
મુખ્ય મુદ્દાઓ:
- Pure Java: કોઈ native code ની જરૂર નથી
- Direct Connection: ડેટાબેઝ સાથે સીધો સંપર્ક કરે છે
- Network Protocol: ડેટાબેઝના native network protocol નો ઉપયોગ કરે છે
- શ્રેષ્ઠ પ્રદર્શન: બધા driver types માં સૌથી ઝડપી
મેમરી ટ્રીક: "Pure Java Direct Protocol"
પ્રશ્ન 2(બ) [4 ગુણ]
Component class ની સામાન્ય રીતે વપરાતી methods સમજાવો.
જવાબ:
કોષ્ટક: Component Class Methods
| Method | હેતુ |
|---|---|
| add() | container માં component ઉમેરે છે |
| setSize() | component ના dimensions સેટ કરે છે |
| setLayout() | layout manager સેટ કરે છે |
| setVisible() | component ને દૃશ્યમાન/અદૃશ્ય બનાવે છે |
| setBounds() | position અને size સેટ કરે છે |
| getSize() | component નું size return કરે છે |
મુખ્ય લક્ષણો:
- Layout Management: component arrangement ને control કરે છે
- Visibility Control: components ને દેખાડે/છુપાવે છે
- Size Management: component dimensions ને control કરે છે
- Container Operations: child components ને manage કરે છે
મેમરી ટ્રીક: "Add Set Get Visibility"
પ્રશ્ન 2(ક) [7 ગુણ]
ટેબલ 'StuRec' માંથી વિદ્યાર્થીના રેકોર્ડ (Enroll No, Name, Address, Mobile No અને Email-ID) દર્શાવવા માટે JDBC નો ઉપયોગ કરીને પ્રોગ્રામ વિકસાવો.
જવાબ:
Java
ડેટાબેઝ ટેબલ માળખું:
SQL
મેમરી ટ્રીક: "Connect Query Display Records"
પ્રશ્ન 2(અ) અથવા [3 ગુણ]
JDBC ના ફાયદા અને ગેરફાયદા લખો.
જવાબ:
કોષ્ટક: JDBC ફાયદા અને ગેરફાયદા
| ફાયદા | ગેરફાયદા |
|---|---|
| Platform Independent | Performance Overhead |
| Database Independent | શરૂઆતી લોકો માટે જટિલ |
| Standard API | SQL dependency |
| Transactions ને support કરે | Manual resource management |
મુખ્ય મુદ્દાઓ:
- પોર્ટેબિલિટી: વિવિધ platforms અને databases પર કામ કરે છે
- સ્ટાન્ડર્ડાઇઝેશન: database operations માટે uniform API
- પ્રદર્શન: વધારાનું layer performance માં overhead લાવે છે
- જટિલતા: યોગ્ય resource management જરૂરી
મેમરી ટ્રીક: "Platform Independent Standard Complex"
પ્રશ્ન 2(બ) અથવા [4 ગુણ]
Border Layout સમજાવો.
જવાબ:
BorderLayout container ને પાંચ વિસ્તારોમાં વહેંચે છે: North, South, East, West, અને Center.
આકૃતિ:
goat
કોષ્ટક: Border Layout વિસ્તારો
| વિસ્તાર | સ્થાન | વર્તન |
|---|---|---|
| NORTH | ઉપર | Preferred height, full width |
| SOUTH | નીચે | Preferred height, full width |
| EAST | જમણે | Preferred width, full height |
| WEST | ડાબે | Preferred width, full height |
| CENTER | વચ્ચે | બાકીની જગ્યા લે છે |
કોડ ઉદાહરણ:
Java
મેમરી ટ્રીક: "North South East West Center"
પ્રશ્ન 2(ક) અથવા [7 ગુણ]
Hibernate CRUD operations નો ઉપયોગ કરીને Employee (NAME, AGE, SALARY અને DEPARTMENT) નો ડેટા store, update, fetch અને delete માટે એપ્લિકેશન ડેવલપ કરો.
જવાબ:
Employee Entity Class:
Java
CRUD Operations Class:
Java
મેમરી ટ્રીક: "Save Get Update Delete Hibernate"
પ્રશ્ન 3(અ) [3 ગુણ]
Deployment Descriptor સમજાવો.
જવાબ:
Deployment Descriptor (web.xml) web applications માટે configuration file છે જેમાં servlet mappings, initialization parameters, અને security settings હોય છે.
કોષ્ટક: Deployment Descriptor Elements
| Element | હેતુ |
|---|---|
| <servlet> | servlet configuration define કરે છે |
| <servlet-mapping> | servlet ને URL pattern સાથે map કરે છે |
| <init-param> | initialization parameters સેટ કરે છે |
| <welcome-file-list> | default files serve કરવા માટે |
મુખ્ય લક્ષણો:
- Configuration: web app માટે કેન્દ્રીય configuration
- Servlet Mapping: URL to servlet mapping
- Parameters: initialization અને context parameters
- Security: authentication અને authorization settings
મેમરી ટ્રીક: "Web XML Configuration Mapping"
પ્રશ્ન 3(બ) [4 ગુણ]
servlet માં get અને post method વચ્ચેનો તફાવત સમજાવો.
જવાબ:
કોષ્ટક: GET vs POST Methods
| લક્ષણ | GET | POST |
|---|---|---|
| Data Location | URL query string | Request body |
| Data Size | મર્યાદિત (2048 chars) | અમર્યાદિત |
| Security | ઓછું સુરક્ષિત (દૃશ્યમાન) | વધુ સુરક્ષિત |
| Caching | Cache થઈ શકે છે | Cache થતું નથી |
| Bookmarking | Bookmark કરી શકાય | Bookmark કરી શકાતું નથી |
| હેતુ | ડેટા retrieve કરવા | ડેટા submit/modify કરવા |
મુખ્ય મુદ્દાઓ:
- દૃશ્યતા: GET ડેટા URL માં દેખાય છે, POST છુપાયેલું હોય છે
- ક્ષમતા: POST મોટો ડેટા handle કરી શકે છે
- સુરક્ષા: POST sensitive ડેટા માટે વધુ સારી
- ઉપયોગ: GET fetching માટે, POST form submission માટે
મેમરી ટ્રીક: "GET Visible Limited, POST Hidden Unlimited"
પ્રશ્ન 3(ક) [7 ગુણ]
એક સરળ servlet પ્રોગ્રામ વિકસાવો જે તેના લોડિંગ પછી કેટલી વખત તેને access કરવામાં આવ્યું છે તેમાટે counter જાળવી રાખે છે; deployment descriptor નો ઉપયોગ કરીને counter ને પ્રારંભ કરો.
જવાબ:
Servlet કોડ:
Java
web.xml Configuration:
xml
મુખ્ય લક્ષણો:
- Thread Safety: synchronized counter increment
- Initialization: web.xml માંથી counter initialized
- Persistent: requests ની વચ્ચે counter maintained
- Configuration: deployment descriptor setup
મેમરી ટ્રીક: "Initialize Synchronize Count Display"
પ્રશ્ન 3(અ) અથવા [3 ગુણ]
servlet ના life cycle સમજાવો.
જવાબ:
Servlet Life Cycle આકૃતિ:
કોષ્ટક: Servlet Life Cycle Methods
| Method | હેતુ | Called |
|---|---|---|
| init() | servlet initialize કરે છે | startup પર એક વખત |
| service() | requests handle કરે છે | દરેક request માટે |
| destroy() | resources cleanup કરે છે | shutdown પર એક વખત |
મુખ્ય મુદ્દાઓ:
- Initialization: servlet load થાય ત્યારે એક વખત call થાય છે
- Service: બધી client requests handle કરે છે
- Cleanup: servlet unload થાય તે પહેલાં call થાય છે
- Container Managed: web container lifecycle ને control કરે છે
મેમરી ટ્રીક: "Initialize Service Destroy"
પ્રશ્ન 3(બ) અથવા [4 ગુણ]
Servlet Config class ને યોગ્ય ઉદાહરણ સાથે સમજાવો.
જવાબ:
ServletConfig servlet-specific configuration information અને initialization parameters પ્રદાન કરે છે.
કોષ્ટક: ServletConfig Methods
| Method | હેતુ |
|---|---|
| getInitParameter() | init parameter value મેળવે છે |
| getInitParameterNames() | બધા parameter names મેળવે છે |
| getServletContext() | servlet context મેળવે છે |
| getServletName() | servlet name મેળવે છે |
ઉદાહરણ:
Java
web.xml:
xml
મેમરી ટ્રીક: "Config Gets Parameters Context"
પ્રશ્ન 3(ક) અથવા [7 ગુણ]
એક સરળ પ્રોગ્રામ ડેવલપ કરો, જ્યારે વપરાશકર્તા subject code પસંદ કરશે, ત્યારે subject નું નામ servlet અને MySQL database નો ઉપયોગ કરીને પ્રદર્શિત થશે.
જવાબ:
HTML Form (index.html):
HTML
Servlet કોડ:
Java
ડેટાબેઝ ટેબલ:
SQL
મેમરી ટ્રીક: "Select Query Display Subject"
પ્રશ્ન 4(અ) [3 ગુણ]
JSP life cycle સમજાવો.
જવાબ:
JSP Life Cycle આકૃતિ:
કોષ્ટક: JSP Life Cycle તબક્કાઓ
| તબક્કો | વર્ણન |
|---|---|
| Translation | JSP to Servlet conversion |
| Compilation | Servlet to bytecode |
| Loading | servlet class ને load કરે છે |
| Initialization | jspInit() call થાય છે |
| Request Processing | _jspService() requests handle કરે છે |
| Destruction | jspDestroy() cleanup |
મેમરી ટ્રીક: "Translate Compile Load Initialize Service Destroy"
પ્રશ્ન 4(બ) [4 ગુણ]
JSP અને Servlet ની સરખામણી કરો.
જવાબ:
કોષ્ટક: JSP vs Servlet સરખામણી
| લક્ષણ | JSP | Servlet |
|---|---|---|
| કોડ પ્રકાર | HTML with Java code | Pure Java code |
| ડેવલપમેન્ટ | web designers માટે સરળ | Java developers માટે વધુ સારું |
| કમ્પાઈલેશન | આપોઆપ | મેન્યુઅલ |
| ફેરફાર | restart ની જરૂર નથી | restart જરૂરી |
| પર્ફોર્મન્સ | પહેલી request ધીમી | ઝડપી |
| જાળવણી | સરળ | જટિલ |
મુખ્ય મુદ્દાઓ:
- ઉપયોગમાં સરળતા: JSP presentation layer માટે સરળ
- પર્ફોર્મન્સ: Servlet business logic માટે વધુ સારું
- લવચીકતા: JSP dynamic content માટે વધુ સારું
- નિયંત્રણ: Servlet વધુ control પ્રદાન કરે છે
મેમરી ટ્રીક: "JSP Easy HTML, Servlet Pure Java"
પ્રશ્ન 4(ક) [7 ગુણ]
Enrollment number દ્વારા વર્તમાન સેમેસ્ટરના દરેક વિષયમાં વિદ્યાર્થીની માસિક હાજરી દર્શાવવા માટે JSP web application ડેવલપ કરો.
જવાબ:
Input Form (attendance.html):
HTML
JSP Page (attendanceCheck.jsp):
jsp
ડેટાબેઝ ટેબલ્સ:
SQL
મેમરી ટ્રીક: "JSP Database Query Display Table"
પ્રશ્ન 4(અ) અથવા [3 ગુણ]
JSP માં implicit objects સમજાવો.
જવાબ:
કોષ્ટક: JSP Implicit Objects
| Object | Type | હેતુ |
|---|---|---|
| request | HttpServletRequest | request ડેટા મેળવે છે |
| response | HttpServletResponse | response મોકલે છે |
| out | JspWriter | client ને output |
| session | HttpSession | session management |
| application | ServletContext | application scope |
| config | ServletConfig | servlet configuration |
| pageContext | PageContext | page scope access |
| page | Object | વર્તમાન servlet instance |
| exception | Throwable | error page exception |
મુખ્ય લક્ષણો:
- આપોઆપ: declaration વિના ઉપલબ્ધ
- Scope Access: વિવિધ scope levels
- Request Handling: input/output operations
- Session Management: વપરાશકર્તા session tracking
મેમરી ટ્રીક: "Request Response Out Session Application"
પ્રશ્ન 4(બ) અથવા [4 ગુણ]
servlet કરતાં JSP શા માટે પસંદ કરવામાં આવે છે તે સમજાવો.
જવાબ:
કોષ્ટક: Servlet કરતાં JSP ના ફાયદા
| પાસું | JSP ફાયદો |
|---|---|
| ડેવલપમેન્ટ | HTML integration સરળ |
| જાળવણી | presentation ને logic થી અલગ કરે |
| કમ્પાઈલેશન | આપોઆપ compilation |
| ફેરફાર | server restart ની જરૂર નથી |
| ડિઝાઈન | web designer friendly |
| કોડ પુનઃઉપયોગ | tag libraries અને custom tags |
મુખ્ય મુદ્દાઓ:
- Separation of Concerns: presentation અને business logic નું સ્પષ્ટ વિભાજન
- ઝડપી ડેવલપમેન્ટ: ઝડપી development cycle
- Designer Friendly: web designers HTML-જેવા syntax સાથે કામ કરી શકે
- આપોઆપ સુવિધાઓ: container compilation અને lifecycle handle કરે
મેમરી ટ્રીક: "Easy HTML Automatic Designer Friendly"
પ્રશ્ન 4(ક) અથવા [7 ગુણ]
પાંચ વિષયોના ગુણ સ્વીકારીને વિદ્યાર્થીના ગ્રેડ દર્શાવવા માટે JSP પ્રોગ્રામ વિકસાવો.
જવાબ:
Input Form (gradeInput.html):
HTML
JSP Grade Calculator (gradeCalculator.jsp):
jsp
ગ્રેડ સ્કેલ કોષ્ટક:
| ટકાવારી | ગ્રેડ | વર્ણન |
|---|---|---|
| 90-100 | A+ | ઉત્કૃષ્ટ |
| 80-89 | A | ખૂબ સારું |
| 70-79 | B | સારું |
| 60-69 | C | સરેરાશ |
| 50-59 | D | સરેરાશથી નીચે |
| 0-49 | F | ફેલ |
મેમરી ટ્રીક: "Calculate Total Percentage Grade Result"
પ્રશ્ન 5(અ) [3 ગુણ]
Aspect-oriented programming (AOP) સમજાવો.
જવાબ:
AOP એ programming paradigm છે જે cross-cutting concerns ને business logic થી aspects નો ઉપયોગ કરીને અલગ કરે છે.
કોષ્ટક: AOP મુખ્ય ખ્યાલો
| ખ્યાલ | વર્ણન |
|---|---|
| Aspect | cross-cutting concern ને encapsulate કરતું module |
| Join Point | program execution માં બિંદુ |
| Pointcut | join points નો સમૂહ |
| Advice | join point પર લેવાતી action |
| Weaving | aspects apply કરવાની પ્રક્રિયા |
મુખ્ય લાભો:
- વિભાજન: business logic ને system services થી અલગ કરે છે
- મોડ્યુલારિટી: કોડ modularity સુધારે છે
- પુનઃઉપયોગ: cross-cutting concerns reusable છે
- જાળવણી: maintain અને modify કરવું સરળ
મેમરી ટ્રીક: "Aspect Join Pointcut Advice Weaving"
પ્રશ્ન 5(બ) [4 ગુણ]
Servlet ની વિવિધ વિશેષતાઓની યાદી બનાવો.
જવાબ:
કોષ્ટક: Servlet વિશેષતાઓ
| વિશેષતા | વર્ણન |
|---|---|
| Platform Independent | Java સપોર્ટ કરતા કોઈપણ server પર ચાલે છે |
| Server Independent | વિવિધ web servers સાથે કામ કરે છે |
| Protocol Independent | HTTP, HTTPS, FTP સપોર્ટ કરે છે |
| Persistent | requests ની વચ્ચે memory માં રહે છે |
| Robust | મજબૂત memory management |
| Secure | Built-in security features |
| Portable | એક વખત લખો, ગમે ત્યાં ચલાવો |
| Powerful | સંપૂર્ણ Java API access |
મુખ્ય મુદ્દાઓ:
- પર્ફોર્મન્સ: CGI કરતાં વધુ સારું પર્ફોર્મન્સ
- Memory Management: કાર્યક્ષમ memory ઉપયોગ
- Multithreading: એકસાથે અનેક requests handle કરે છે
- Extensible: ચોક્કસ protocols માટે extend કરી શકાય છે
મેમરી ટ્રીક: "Platform Server Protocol Persistent Robust"
પ્રશ્ન 5(ક) [7 ગુણ]
Model layer, View layer અને Controller layer ને વિગતોમાં સમજાવો.
જવાબ:
MVC આર્કિટેક્ચર આકૃતિ:
કોષ્ટક: MVC Layer વિગતો
| Layer | જવાબદારી | Components | હેતુ |
|---|---|---|---|
| Model | ડેટા અને business logic | Entities, DAOs, Services | ડેટા management |
| View | Presentation layer | JSP, HTML, CSS | વપરાશકર્તા interface |
| Controller | Request handling | Servlets, Actions | Flow control |
Model Layer વિગતો:
- ડેટા Access: ડેટાબેઝ operations અને data persistence
- Business Logic: મુખ્ય application logic અને rules
- Validation: ડેટા validation અને integrity checks
- Entity Classes: ડેટા structures ને represent કરતા Java beans
ઉદાહરણ Model:
Java
View Layer વિગતો:
- Presentation: વપરાશકર્તા interface rendering
- Display Logic: વપરાશકર્તાને ડેટા કેવી રીતે present કરવો
- User Interaction: forms, buttons, navigation
- Responsive Design: વિવિધ devices માટે adapt થાય છે
Controller Layer વિગતો:
- Request Handling: વપરાશકર્તાની requests process કરે છે
- Flow Control: આગળનું કયું view display કરવું તે નક્કી કરે છે
- Model Coordination: યોગ્ય model methods ને call કરે છે
- Response Generation: વપરાશકર્તા માટે response તૈયાર કરે છે
ઉદાહરણ Controller:
Java
MVC ના ફાયદા:
- Separation of Concerns: જવાબદારીનું સ્પષ્ટ વિભાજન
- Maintainability: maintain અને modify કરવું સરળ
- Testability: દરેક layer ને અલગ થી test કરી શકાય
- Scalability: મોટા application development ને સપોર્ટ કરે છે
- Team Development: અનેક developers એકસાથે કામ કરી શકે છે
મેમરી ટ્રીક: "Model Data View Present Controller Handle"
પ્રશ્ન 5(અ) અથવા [3 ગુણ]
Spring Boot ની વિશેષતાઓ સમજાવો.
જવાબ:
કોષ્ટક: Spring Boot વિશેષતાઓ
| વિશેષતા | વર્ણન |
|---|---|
| Auto Configuration | dependencies આધારે આપોઆપ configuration |
| Starter Dependencies | curated dependencies નો સેટ |
| Embedded Servers | built-in Tomcat, Jetty servers |
| Production Ready | health checks, metrics, monitoring |
| No XML Configuration | annotation-based configuration |
| Developer Tools | hot reloading, automatic restart |
મુખ્ય લાભો:
- ઝડપી ડેવલપમેન્ટ: ઝડપી project setup અને development
- Convention over Configuration: sensible defaults
- Microservices Ready: સરળ microservices development
- Cloud Native: cloud deployment માટે તૈયાર
મેમરી ટ્રીક: "Auto Starter Embedded Production Annotation Developer"
પ્રશ્ન 5(બ) અથવા [4 ગુણ]
JSP scripting elements પર ટૂંકી નોંધ લખો.
જવાબ:
કોષ્ટક: JSP Scripting Elements
| Element | Syntax | હેતુ | ઉદાહરણ |
|---|---|---|---|
| Scriptlet | <% %> | Java code execution | <% int x = 10; %> |
| Expression | <%= %> | Output value | <%= x + 5 %> |
| Declaration | <%! %> | Variable/method declaration | <%! int count = 0; %> |
| Directive | <%@ %> | Page configuration | <%@ page import="java.util.*" %> |
| Comment | <%-- --%> | JSP comments | <%-- આ comment છે --%> |
ઉદાહરણો:
jsp
મુખ્ય મુદ્દાઓ:
- Scriptlet: Java statements ધરાવે છે
- Expression: result evaluate કરે અને output આપે છે
- Declaration: instance variables/methods બનાવે છે
- Directive: page-level માહિતી પ્રદાન કરે છે
મેમરી ટ્રીક: "Script Express Declare Direct Comment"
પ્રશ્ન 5(ક) અથવા [7 ગુણ]
Dependency injection (DI) અને Plain Old Java Object (POJO) ને વિગતોમાં સમજાવો.
જવાબ:
Dependency Injection (DI):
Dependency Injection એ design pattern છે જ્યાં objects તેમની dependencies external source માંથી receive કરે છે internal creation કરવાને બદલે.
કોષ્ટક: DI પ્રકારો
| પ્રકાર | વર્ણન | ઉદાહરણ |
|---|---|---|
| Constructor Injection | constructor દ્વારા dependencies | public Service(Repository repo) |
| Setter Injection | setter methods દ્વારા dependencies | setRepository(Repository repo) |
| Field Injection | સીધું field injection | @Autowired Repository repo |
DI ઉદાહરણ:
Java
Spring DI Configuration:
Java
Plain Old Java Object (POJO):
POJO એ સરળ Java object છે જે કોઈ ચોક્કસ framework classes માંથી inherit કરતું નથી અથવા ચોક્કસ interfaces implement કરતું નથી.
POJO લાક્ષણિકતાઓ:
- કોઈ inheritance નથી: framework classes માંથી extend કરતું નથી
- કોઈ interfaces નથી: framework interfaces implement કરતું નથી
- કોઈ annotations નથી: framework annotations વિના કામ કરી શકે છે
- સરળ: માત્ર business logic અને ડેટા ધરાવે છે
POJO ઉદાહરણ:
Java
DI ના ફાયદા:
- Loose Coupling: classes વચ્ચે dependencies ઘટાડે છે
- Testability: testing માટે mock objects inject કરવું સરળ
- Flexibility: implementations બદલવું સરળ
- Maintainability: કોડ maintain અને extend કરવું સરળ
POJO ના ફાયદા:
- સરળતા: સમજવું અને maintain કરવું સરળ
- Testability: unit test કરવું સરળ
- Portability: વિવિધ frameworks માં ઉપયોગ કરી શકાય
- Lightweight: કોઈ framework overhead નથી
DI અને POJO એકસાથે:
Java
મેમરી ટ્રીક: "DI Injects Dependencies, POJO Plain Objects"