पहले 10 प्रश्नों के उत्तर और हल यहीं खुले हैं; बाक़ी 20 के उत्तर और हल FliQi Question Bank app में।
भाषा
प्रश्न 1उत्तर + हल
"use-a" संबंध का उपयोग करने का निम्नलिखित में से कौन-सा लाभ है?
Which of the following is an advantage of using a "use-a" relationship?
Aइससे क्लासों के बीच मज़बूत जुड़ाव (tight coupling) बनता है।It leads to tight coupling between classes.
Bइससे कोड की पुनः उपयोगिता (code reusability) बढ़ती है।It enhances code reusability.
Cइससे कोडबेस का लचीलापन (flexibility) घटता है।It reduces the flexibility of the codebase.
Dइससे क्लासों का डिज़ाइन जटिल हो जाता है।It complicates the design of the classes.
सही उत्तर / Answer: (B)
हल / Solution
"use-a" संबंध में एक क्लास वही logic दोबारा लिखने के बजाय दूसरी क्लास की बनी-बनाई methods कॉल करती है। एक ही सहायक क्लास, जैसे Calculator या Logger, कई क्लासों के काम आ जाती है। इससे कोड की पुनः उपयोगिता (code reusability) बढ़ती है। यह जुड़ाव ढीला (loose coupling) होता है। मज़बूत जुड़ाव (tight coupling), कम लचीलापन (flexibility) और जटिल डिज़ाइन तो नुक़सान हैं, लाभ नहीं। इसलिए विकल्प 2 सही है।
In a "use-a" relationship a class calls the ready-made methods of another class instead of writing that logic again. The same helper class, such as a Calculator or Logger, can then serve many classes, so code reusability increases. The link is loose, so it does not create tight coupling. Tight coupling, lower flexibility and a more complex design are disadvantages, not advantages. So option 2 is correct.
प्रश्न 2उत्तर + हल
"use-a" संबंध में मुख्य ध्यान किस बात पर होता है?
In a "use-a" relationship, what is the primary focus?
Aक्लासों के बीच डेटा साझा करना।Sharing data between classes.
Bक्लासों के अंदर व्यवहार (behavior) को एनकैप्सुलेट (encapsulate) करना।Encapsulating behavior within classes.
Cदूसरी क्लास द्वारा दी गई कार्यक्षमता (functionality) का पुनः उपयोग (reuse) करना।Reusing functionality provided by another class.
Dक्लासों के बीच पदानुक्रम (hierarchy) वाले संबंध बनाना।Establishing hierarchical relationships between classes.
सही उत्तर / Answer: (C)
हल / Solution
"use-a" संबंध का मुख्य उद्देश्य दूसरी क्लास में पहले से बनी कार्यक्षमता (functionality) का पुनः उपयोग (reuse) करना है। एक क्लास वही logic दोबारा लिखने के बजाय दूसरी क्लास की methods कॉल कर लेती है। जैसे log लिखने के लिए Logger क्लास का उपयोग करना। डेटा साझा करना इसका लक्ष्य नहीं है। व्यवहार को छिपाना एनकैप्सुलेशन (Encapsulation) का अलग सिद्धांत है। पदानुक्रम (hierarchy) बनाना इनहेरिटेंस (Inheritance) का काम है। इसलिए विकल्प 3 सही है।
The main purpose of a "use-a" relationship is to reuse functionality that another class already provides. Instead of writing the same logic again, a class simply calls the other class's methods, such as using a Logger to write logs. Sharing data is not its goal. Encapsulating behavior is a separate OOP principle. Building class hierarchies is the job of inheritance, the "is-a" relationship. So option 3 is correct.
प्रश्न 3उत्तर + हल
Java में "use-a" संबंध आमतौर पर कैसे लागू (implement) किया जाता है?
In Java, how is a "use-a" relationship typically implemented?
Aइनहेरिटेंस (inheritance) के द्वारा।Through inheritance.
Bकम्पोज़िशन (composition) के द्वारा।Through composition.
Cएग्रीगेशन (aggregation) के द्वारा।Through aggregation.
Dमेथड इनवोकेशन (method invocation) के द्वारा।Through method invocation.
सही उत्तर / Answer: (D)
हल / Solution
"use-a" संबंध आमतौर पर मेथड इनवोकेशन (method invocation) से बनता है। एक क्लास दूसरी क्लास का ऑब्जेक्ट method के parameter में लेती है या method के अंदर बनाती है। फिर केवल उस काम के लिए उसकी methods कॉल करती है। जैसे Driver.drive(Car c) के अंदर c.start() कॉल होना। इनहेरिटेंस (Inheritance) "is-a" संबंध देता है। कम्पोज़िशन (Composition) और एग्रीगेशन (Aggregation) "has-a" संबंध देते हैं। इसलिए विकल्प 4 सही है।
A "use-a" relationship is usually built through method invocation. One class receives an object of another class as a method parameter, or creates it locally, and calls its methods only for that task. For example, Driver.drive(Car c) calls c.start(). Inheritance gives an "is-a" relationship. Composition and aggregation give "has-a" relationships, where the other object is kept as a field. So option 4 is correct.
प्रश्न 4उत्तर + हल
"use-a" संबंध में एक क्लास द्वारा दूसरी क्लास का "उपयोग" करने का क्या अर्थ है?
In a "use-a" relationship, what does it mean for one class to use another class?
Aइसका अर्थ है कि एक क्लास दूसरी क्लास की subclass है।It means one class is a subclass of another class.
Bइसका अर्थ है कि एक क्लास दूसरी क्लास के ऑब्जेक्टों से मिलकर बनी है।It means one class is composed of objects of another class.
Cइसका अर्थ है कि एक क्लास में ऐसी methods हैं जो दूसरी क्लास की methods को कॉल (invoke) करती हैं।It means one class contains methods that invoke methods of another class.
Dइसका अर्थ है कि एक क्लास दूसरी क्लास के साथ instance variables साझा करती है।It means one class shares instance variables with another class.
सही उत्तर / Answer: (C)
हल / Solution
जब एक क्लास दूसरी क्लास का "उपयोग" करती है, तो उसकी अपनी methods दूसरी क्लास की methods कॉल करके काम करवाती हैं। जैसे Printer क्लास की कोई method, Formatter ऑब्जेक्ट की format() method कॉल कर सकती है। subclass होना इनहेरिटेंस (Inheritance) यानी "is-a" संबंध है। दूसरी क्लास के ऑब्जेक्टों से बना होना कम्पोज़िशन (Composition) यानी "has-a" संबंध है। "use-a" में instance variables साझा नहीं होते। इसलिए विकल्प 3 सही है।
When one class "uses" another, its own methods call the methods of the other class to get some work done. For example, a Printer class method may call a Formatter object's format() method. Being a subclass is inheritance, an "is-a" relationship. Being made up of objects of another class is composition, a "has-a" relationship. Classes do not share instance variables in a "use-a" relationship. So option 3 is correct.
प्रश्न 5उत्तर + हल
निम्नलिखित में से कौन-सा Java में "use-a" संबंध का उदाहरण है?
Which of the following is an example of a "use-a" relationship in Java?
Aडेटाबेस कनेक्शन को दर्शाने वाली क्लास, जो JDBC का उपयोग करती है।A class representing a database connection using JDBC.
Bविश्वविद्यालय को दर्शाने वाली क्लास, जिसमें छात्रों की सूची है।A class representing a university with a list of students.
Cकार को दर्शाने वाली क्लास, जिसमें इंजन ऑब्जेक्ट है।A class representing a car with an engine object.
Dआकृति (shape) को दर्शाने वाली क्लास, जिसकी circle, square और triangle नाम की subclasses हैं।A class representing a shape with subclasses for circle, square, and triangle.
सही उत्तर / Answer: (A)
हल / Solution
डेटाबेस कनेक्शन वाली क्लास अपना काम करने के लिए JDBC (Java Database Connectivity) की क्लासों, जैसे DriverManager और Connection, का उपयोग करती है। वह उनकी methods कॉल करती है, उन्हें अपना हिस्सा नहीं बनाती। इसलिए यह "use-a" यानी डिपेंडेंसी (Dependency) संबंध है। छात्रों की सूची वाला विश्वविद्यालय और इंजन वाली कार "has-a" संबंध हैं। Shape और उसकी subclasses इनहेरिटेंस (Inheritance) यानी "is-a" संबंध हैं। इसलिए विकल्प 1 सही है।
A class that represents a database connection uses JDBC classes such as DriverManager and Connection to do its job. It calls their methods but they are not its parts, so it is a "use-a" (dependency) relationship. A university holding a list of students and a car holding an engine object are "has-a" relationships (aggregation and composition). Shape with Circle, Square and Triangle subclasses is inheritance, an "is-a" relationship.
प्रश्न 6उत्तर + हल
"use-a" संबंध में एक क्लास की कार्यक्षमता (functionality) का उपयोग दूसरी क्लास किस प्रकार करती है?
In a "use-a" relationship, how is the functionality of one class utilized by another class?
Aइनहेरिटेंस (inheritance) के द्वारा।Through inheritance.
Bकम्पोज़िशन (composition) के द्वारा।Through composition.
Cमेथड इनवोकेशन (method invocation) के द्वारा।Through method invocation.
Dडेटा साझा करने (data sharing) के द्वारा।Through data sharing.
सही उत्तर / Answer: (C)
हल / Solution
"use-a" संबंध में एक क्लास दूसरी क्लास की methods कॉल करके अपना काम करवाती है। इसे मेथड इनवोकेशन (method invocation) कहते हैं। जैसे Order क्लास अपनी किसी method के अंदर paymentService.pay() कॉल कर सकती है। इनहेरिटेंस (Inheritance) "is-a" संबंध बनाता है। कम्पोज़िशन (Composition) दूसरे ऑब्जेक्ट को स्थायी हिस्सा बनाकर "has-a" संबंध बनाता है। डेटा साझा करना इस संबंध का तरीक़ा नहीं है। इसलिए विकल्प 3 सही है।
In a "use-a" relationship, one class gets work done by another class by calling its methods. For example, an Order class may call paymentService.pay() inside one of its methods. This is method invocation. Inheritance creates an "is-a" link, and composition makes the other object a permanent part, a "has-a" link. Data sharing between classes is not how this relationship works. So option 3 is correct.
प्रश्न 7उत्तर + हल
Java में "use-a" संबंध क्या है?
What is a "use-a" relationship in Java?
Aयह क्लासों के बीच मज़बूत जुड़ाव (strong coupling) दर्शाता है।It represents a strong coupling between classes.
Bयह ऐसा संबंध दर्शाता है जिसमें एक क्लास दूसरी क्लास की कार्यक्षमता (functionality) का उपयोग करती है।It represents a relationship where one class utilizes the functionality of another class.
Cयह क्लासों के बीच इनहेरिटेंस (inheritance) संबंध दर्शाता है।It represents an inheritance relationship between classes.
Dयह क्लासों के बीच कम्पोज़िशन (composition) संबंध दर्शाता है।It represents a composition relationship between classes.
सही उत्तर / Answer: (B)
हल / Solution
"use-a" संबंध को डिपेंडेंसी (Dependency) भी कहते हैं। इसमें एक क्लास दूसरी क्लास की कार्यक्षमता (functionality) का केवल उपयोग करती है। जैसे किसी method के अंदर उसकी method कॉल करना या उसे parameter में लेना। वह दूसरे ऑब्जेक्ट को अपना स्थायी हिस्सा नहीं बनाती। यह जुड़ाव ढीला (loose coupling) होता है, मज़बूत नहीं। इनहेरिटेंस (Inheritance) "is-a" संबंध है और कम्पोज़िशन (Composition) मज़बूत "has-a" संबंध है। इसलिए विकल्प 2 सही है।
In a "use-a" relationship, also called dependency, one class simply uses the services of another class, for example by calling its methods inside a method or receiving it as a parameter. It does not keep the other object as a permanent part. This link is loose, not strong coupling. Inheritance is an "is-a" relationship, and composition is a strong "has-a" relationship, so option 2 is correct.
प्रश्न 8उत्तर + हल
निम्नलिखित में से कौन-सा संबंध एसोसिएशन (association) का अधिक मज़बूत रूप है?
Which of the following relationships represents a stronger form of association?
Aएग्रीगेशन (Aggregation)Aggregation
Bकम्पोज़िशन (Composition)Composition
Cडिपेंडेंसी (Dependency)Dependency
Dइनहेरिटेंस (Inheritance)Inheritance
सही उत्तर / Answer: (B)
हल / Solution
कम्पोज़िशन (Composition) एसोसिएशन का सबसे मज़बूत रूप है। इसमें हिस्सा (part) पूरी तरह संपूर्ण (whole) का होता है और उसके बिना नहीं रह सकता। जैसे House ऑब्जेक्ट नष्ट हो तो उसके Room भी नष्ट हो जाते हैं। एग्रीगेशन (Aggregation) कमज़ोर "has-a" संबंध है, जिसमें हिस्सा अलग भी रह सकता है। डिपेंडेंसी (Dependency) केवल अस्थायी "uses-a" संबंध है। इनहेरिटेंस (Inheritance) "is-a" संबंध है, एसोसिएशन नहीं।
Composition is the strongest form of association. In it the part object belongs fully to the whole and cannot exist without it; when a House object is destroyed, its Room objects go with it. Aggregation is a weaker "has-a" link where the part can live on its own, like a Department and its Teachers. Dependency is only a temporary "uses-a" link, and Inheritance is an "is-a" relationship, not association.
प्रश्न 9उत्तर + हल
Java में जब दो क्लासें एसोसिएटेड (associated) होती हैं, तो इसका क्या अर्थ है?
In Java, what does it mean when two classes are associated?
Aउनकी सुपरक्लास (superclass) एक ही होनी चाहिए।They must have the same superclass.
Bवे एक जैसे instance variables साझा करती हैं।They share the same instance variables.
Cएक क्लास के ऑब्जेक्ट दूसरी क्लास की methods को कॉल (invoke) कर सकते हैं।Objects of one class can invoke methods of the other class.
Dउन्हें एक ही package में घोषित करना ज़रूरी है।They must be declared within the same package.
सही उत्तर / Answer: (C)
हल / Solution
दो क्लासें तब एसोसिएटेड (associated) कहलाती हैं जब एक क्लास का ऑब्जेक्ट दूसरी क्लास के ऑब्जेक्ट को जानता है। आमतौर पर वह उसका reference रखता है। उसी reference से वह दूसरी क्लास की methods कॉल कर सकता है, इसलिए विकल्प 3 सही है। एक ही सुपरक्लास (superclass) की शर्त इनहेरिटेंस (Inheritance) की बात है। दोनों क्लासें अपने-अपने instance variables रखती हैं, साझा नहीं करतीं। वे अलग-अलग package में भी हो सकती हैं।
Two classes are associated when an object of one class knows an object of the other, usually by holding its reference. Through that reference it can call the other object's methods, so option 3 is correct. Association does not need a common superclass; that is about inheritance. The classes keep their own instance variables and do not share them. They can also live in different packages, if access rules allow.
प्रश्न 10उत्तर + हल
निम्नलिखित में से कौन-सा Java में एसोसिएशन (association) का उदाहरण नहीं है?
Which of the following is NOT an example of association in Java?
Aकार में एक इंजन होता है।A car has an engine.
Bविश्वविद्यालय में छात्र होते हैं।A university has students.
Cएक व्यक्ति अपने माता-पिता से गुण विरासत में पाता है।A person inherits traits from their parents.
Dपुस्तकालय में पुस्तकें होती हैं।A library contains books.
सही उत्तर / Answer: (C)
हल / Solution
एसोसिएशन (Association) वस्तुओं के बीच "has-a" संबंध है। कार में इंजन, विश्वविद्यालय में छात्र और पुस्तकालय में पुस्तकें — तीनों "has-a" संबंध हैं। इसलिए ये एसोसिएशन के रूप हैं, यानी कम्पोज़िशन (Composition) या एग्रीगेशन (Aggregation)। माता-पिता से गुण विरासत में पाना "is-a" वाला विचार है। Java इसे इनहेरिटेंस (Inheritance) से दिखाता है, जिसमें extends keyword लगता है। इसलिए विकल्प 3 एसोसिएशन का उदाहरण नहीं है।
Association is a "has-a" link between objects. A car has an engine, a university has students and a library contains books; each is a "has-a" relationship, so all three are forms of association (composition or aggregation). A person inheriting traits from parents describes an "is-a" idea, which Java models with inheritance using the extends keyword, not association. So option 3 is the one that is not association.
आगे के 20 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
composition और aggregation के बारे में इनमें से कौन कथन सही है?
Which of the following statements about composition and aggregation is true?
AComposition, aggregation से ज़्यादा मज़बूत संबंध है।Composition is a stronger form of relationship than aggregation.
BAggregation में भीतर का object container के constructor में ही बनाना ज़रूरी है।Aggregation requires the contained object to be created inside the container's constructor.
CAggregation में संबंध चलते-चलते बदला जा सकता है, composition में नहीं।Aggregation allows for dynamic changes in the relationship, whereas composition does not.
DComposition से aggregation की तुलना में हमेशा हल्की coupling बनती है।Composition always leads to a weaker coupling between classes compared to aggregation.
Java में composition को इनमें से कौन सबसे ठीक बताता है?
Which of the following best describes composition in Java?
Aयह ऐसा "whole-part" संबंध है जिसमें हिस्से पूरे के बिना नहीं रह सकतेIt represents a "whole-part" relationship where the parts cannot exist independently of the whole
Bयह ऐसा "whole-part" संबंध है जिसमें हिस्से पूरे के बिना भी रह सकते हैंIt represents a "whole-part" relationship where the parts can exist independently of the whole
Cयह aggregation से भी हल्का coupling बनाता हैIt implies a weaker coupling between classes compared to aggregation
Dयह classes के बीच दोतरफ़ा संबंध बनाता हैIt implies a bidirectional relationship between classes
Which of the following scenarios is an example of aggregation?
Aएक विश्वविद्यालय में विभाग हैं, और हर विभाग में छात्र हैं।A university has departments, and each department has students.
Bकार में इंजन है, और कार के बिना इंजन बेकार है।A car has an engine, and the engine is useless without the car.
Cघर में कमरे हैं, और घर गिराने पर कमरे भी नहीं बचते।A house has rooms, and the rooms are destroyed when the house is demolished.
Dव्यक्ति के पास हृदय है, और व्यक्ति के मरने पर हृदय काम करना बंद कर देता है।A person has a heart, and the heart stops functioning when the person dies.
Java में aggregation आम तौर पर कैसे दर्शाया जाता है?
In Java, how is aggregation typically represented?
A"extends" keyword लगाकर।By using the "extends" keyword.
B"implements" keyword लगाकर।By using the "implements" keyword.
Cclass के अंदर "new" से दूसरी class का instance बनाकर, यानी composition से।By using composition with the "new" keyword to create an instance of another class within a class.
Dclasses के बीच "has-a" संबंध रखकर।By using the "has-a" relationship between classes.
Java में aggregation के बारे में इनमें से कौन कथन सही है?
Which of the following statements about aggregation in Java is true?
AAggregation "whole-part" संबंध दर्शाता है।Aggregation represents a "whole-part" relationship.
BAggregation से classes के बीच हमेशा मज़बूत coupling बनती है।Aggregation always leads to a strong coupling between classes.
CAggregation में container मिटते ही भीतर रखा object भी मिट जाता है।In aggregation the contained object is destroyed as soon as the container is destroyed.
DAggregation मालिकाने और ज़िम्मेदारी का अर्थ देता है।Aggregation implies ownership and responsibility.