FliQi Education App Download
प्रश्न-बैंक · Java

OOPs Concept (Basic) — प्रश्न और उत्तर

Java · 69 जाँचे हुए (verified) प्रश्न

  • 69 जाँचे हुए प्रश्न
  • हिंदी + English

पहले 10 प्रश्नों के उत्तर और हल यहीं खुले हैं; बाक़ी 20 के उत्तर और हल FliQi Question Bank app में।

भाषा
प्रश्न 1उत्तर + हल
अलग-अलग ऑब्जेक्ट बनाने के लिए टेम्पलेट (साँचा) कौन-सा है?
Which one is a template for creating different objects?
  1. Aऐरे (Array)An Array
  2. Bक्लास (Class)A class
  3. Cइंटरफ़ेस (Interface)Interface
  4. Dमेथड (Method)Method

सही उत्तर / Answer: (B)

हल / Solution
class एक साँचे या नक़्शे की तरह है। इसमें लिखा रहता है कि object में कौन-से variables (data) और कौन-से methods (काम) होंगे। एक ही class से new लगाकर कई अलग-अलग object बनाए जा सकते हैं, हर एक का अपना data होता है। array सिर्फ़ एक जैसे मानों का समूह है। interface का object सीधे नहीं बनता, उसे कोई class implement करती है। method तो class के अंदर का एक काम है।
A class works like a template or blueprint. It states which variables (data) and which methods (behaviour) an object will have. Using new, many different objects can be created from one class, each with its own data. An array is only a group of values of the same type. An interface cannot be instantiated directly; a class has to implement it. A method is just one task inside a class.
प्रश्न 2उत्तर + हल
जावा में "this" कीवर्ड का कौन-सा उपयोग नहीं है?
What is not the use of the "this" keyword in Java?
  1. Aलोकल वेरिएबल का नाम एक जैसा होने पर इंस्टेंस वेरिएबल को रेफ़र करनाReferring to the instance variable when a local variable has the same name
  2. Bस्वयं को उसी क्लास के मेथड में पास करनाPassing itself to the method of the same class
  3. Cस्वयं को किसी दूसरे मेथड में पास करनाPassing itself to another method
  4. Dकंस्ट्रक्टर चेनिंग में दूसरे कंस्ट्रक्टर को कॉल करनाCalling another constructor in constructor chaining

सही उत्तर / Answer: (B)

हल / Solution
this मौजूदा object का reference है। इसके मुख्य उपयोग हैं: parameter और instance variable का नाम एक जैसा हो तो this.x से instance variable बताना, this() से उसी class का दूसरा constructor बुलाना, और this को argument बनाकर किसी दूसरे method या object को भेजना। उसी class के instance method के पास this पहले से होता है, इसलिए उसे this पास करने की ज़रूरत नहीं पड़ती। इसे this का उपयोग नहीं गिना जाता।
this is a reference to the current object. Its main uses are: using this.x to reach the instance variable when a parameter has the same name, using this() to call another constructor of the same class, and passing this as an argument to another method or object. An instance method of the same class already has this, so there is no need to pass it there. That is not counted as a use of this.
प्रश्न 3उत्तर + हल
निम्नलिखित में से कौन जावा में OOPS अवधारणा नहीं है?
Which of the following is not an OOPS concept in Java?
  1. Aपॉलीमॉर्फ़िज़्म (Polymorphism)Polymorphism
  2. Bइनहेरिटेंस (Inheritance)Inheritance
  3. Cकंपाइलेशन (Compilation)Compilation
  4. Dएनकैप्सुलेशन (Encapsulation)Encapsulation

सही उत्तर / Answer: (C)

हल / Solution
OOPS की चार मुख्य अवधारणाएँ हैं: encapsulation, inheritance, polymorphism और abstraction। ये सब बताती हैं कि classes और objects के साथ program कैसे बनाया जाए। compilation इनमें नहीं है। compilation तो source code को byte code या machine code में बदलने की प्रक्रिया है, जो हर भाषा में होती है, चाहे वह object-oriented हो या न हो। इसलिए उत्तर compilation है।
The four main OOPS concepts are encapsulation, inheritance, polymorphism and abstraction. They describe how to build a program with classes and objects. Compilation is not one of them. Compilation is the process of turning source code into byte code or machine code, and it happens in every language, whether object-oriented or not. So the answer is compilation, which is option 3.
प्रश्न 4उत्तर + हल
एनकैप्सुलेशन को और क्या कहा जाता है?
Encapsulation is also called?
  1. Aडेटा हायरिंग (Data hiring)Data hiring
  2. Bडेटा हाइडिंग (Data hiding)Data hiding
  3. Cडेटा एब्स्ट्रैक्शन (Data abstraction)Data abstraction
  4. Dकोई नहींNone

सही उत्तर / Answer: (B)

हल / Solution
encapsulation में class के data को private रखकर बाहर से छिपाया जाता है और उस तक पहुँच सिर्फ़ methods से दी जाती है। इसलिए इसे data hiding भी कहते हैं। data hiring कोई शब्द नहीं, यह hiding से मिलता-जुलता भ्रम वाला विकल्प है। data abstraction अलग अवधारणा है। उसमें ज़रूरी बातें दिखाई जाती हैं और भीतर का ढंग छिपाया जाता है, जैसे abstract class और interface से।
In encapsulation, the data of a class is kept private and hidden from outside, and access is given only through methods. That is why it is also called data hiding. Data hiring is not a real term; it is a look-alike distractor. Data abstraction is a different concept. It shows only the essential features and hides how things work inside, as done with abstract classes and interfaces.
प्रश्न 5उत्तर + हल
एनकैप्सुलेशन कैसे प्राप्त किया जा सकता है?
How can encapsulation be achieved?
  1. Aएक्सेस स्पेसिफ़ायर का उपयोग करकेUsing access specifiers
  2. Bइनहेरिटेंस का उपयोग करकेUsing inheritance
  3. Cकेवल private सदस्यों का उपयोग करकेUsing only private members
  4. Dकोई नहींNone

सही उत्तर / Answer: (A)

हल / Solution
encapsulation में data को छिपाकर उस तक पहुँच नियंत्रित की जाती है। यह access specifiers से होता है: variables को private रखा जाता है और getter-setter जैसे methods को public। यानी private और public दोनों का मिला-जुला उपयोग चाहिए। सिर्फ़ private सदस्य रखें तो data तक कोई पहुँच ही नहीं बचेगी, इसलिए विकल्प 3 अधूरा है। inheritance गुण लेने की अवधारणा है, data छिपाने की नहीं।
Encapsulation hides data and controls access to it. This is done with access specifiers: variables are kept private and methods such as getters and setters are made public. So both private and public are used together. With only private members, there would be no way to reach the data at all, so option 3 is incomplete. Inheritance is about taking features from a class, not about hiding data.
प्रश्न 6उत्तर + हल
जावा में एनकैप्सुलेशन प्राप्त करने के कितने तरीक़े हैं?
How many ways are there to achieve encapsulation in Java?
  1. A3
  2. B2
  3. C4
  4. Dकोई नहींNone

सही उत्तर / Answer: (B)

हल / Solution
Java में encapsulation दो क़दमों से मिलता है। पहला, class के variables को private बनाइए, ताकि बाहर की class उन्हें सीधे न छू सके। दूसरा, उन variables को पढ़ने और बदलने के लिए public getter और setter methods दीजिए। इस तरह data छिपा रहता है और उस तक पहुँच सिर्फ़ नियंत्रित methods से होती है। इसलिए encapsulation पाने के दो तरीक़े माने जाते हैं और उत्तर 2 है।
In Java, encapsulation is achieved in two steps. First, make the variables of the class private, so outside classes cannot touch them directly. Second, provide public getter and setter methods to read and change those variables. This way the data stays hidden and can be reached only through controlled methods. So encapsulation is said to be achieved in two ways, and the answer is 2.
प्रश्न 7उत्तर + हल
हम रैपर क्लास (wrapper class) का उपयोग क्यों करते हैं?
Why do we use a wrapper class?
  1. Aप्रिमिटिव डेटा टाइप को ऑब्जेक्ट में बदलने के लिएTo convert primitive data types into objects
  2. Bनॉन-प्रिमिटिव डेटा टाइप को ऑब्जेक्ट में बदलने के लिएTo convert non-primitive data types into objects
  3. CA और B दोनोंBoth A & B
  4. Dइनमें से कोई नहींNone of these

सही उत्तर / Answer: (A)

हल / Solution
int, char, double जैसे primitive types object नहीं होते। पर collections जैसे ArrayList में सिर्फ़ object रखे जा सकते हैं। इसलिए हर primitive के लिए एक wrapper class है, जैसे int के लिए Integer और char के लिए Character। ये primitive मान को object में लपेट देती हैं। non-primitive types, जैसे String या array, पहले से ही object हैं, उन्हें बदलने की ज़रूरत नहीं। इसलिए विकल्प 2 और 3 ग़लत हैं।
Primitive types like int, char and double are not objects. But collections such as ArrayList can hold only objects. So there is a wrapper class for each primitive, such as Integer for int and Character for char. These wrap a primitive value inside an object. Non-primitive types like String or arrays are already objects, so they need no conversion. That is why options 2 and 3 are wrong.
प्रश्न 8उत्तर + हल
जावा में एकाधिक (multiple) वंशानुक्रम प्राप्त करने के लिए किस अवधारणा का उपयोग किया जाता है?
Which concept is used to achieve multiple inheritance in Java?
  1. AIS-A संबंधIS-A Relationship
  2. BInteract
  3. Cइंटरफ़ेस (Interface)Interface
  4. Dइनमें से कोई नहींNone of these

सही उत्तर / Answer: (C)

हल / Solution
Java में एक class सिर्फ़ एक ही class को extends कर सकती है, ताकि दो parent में एक ही नाम के method होने पर उलझन न हो। पर एक class कई interfaces को implement कर सकती है, जैसे class A implements X, Y। इसी तरह Java में multiple inheritance मिलता है। IS-A संबंध तो हर inheritance में बनता है, वह multiple का साधन नहीं है। Interact नाम की कोई अवधारणा Java में नहीं है।
In Java a class can extend only one class, which avoids confusion when two parents have methods with the same name. But a class can implement many interfaces, such as class A implements X, Y. This is how Java achieves multiple inheritance. The IS-A relationship is formed in every inheritance, so it is not the tool for multiple inheritance. There is no concept called Interact in Java.
प्रश्न 9उत्तर + हल
हम जावा में वंशानुक्रम (Inheritance) का उपयोग क्यों करते हैं?
Why do we use inheritance in Java?
  1. Aमेथड ओवरराइडिंग के लिएFor method overriding
  2. Bकोड के पुनः उपयोग (Code Reusability) के लिएFor code reusability
  3. CA और B दोनोंBoth A & B
  4. Dइनमें से कोई नहींNone of these

सही उत्तर / Answer: (C)

हल / Solution
inheritance के दो बड़े फ़ायदे हैं। पहला, code का दोबारा उपयोग: parent class में लिखा code child class को अपने आप मिल जाता है, उसे फिर से लिखना नहीं पड़ता। दूसरा, method overriding: child class parent के method को अपने ढंग से दोबारा लिख सकती है, जिससे runtime polymorphism मिलता है। overriding बिना inheritance के हो ही नहीं सकती। इसलिए दोनों कारण सही हैं और उत्तर 'A और B दोनों' है।
Inheritance has two main benefits. First, code reusability: code written in the parent class is available to the child class without writing it again. Second, method overriding: the child class can rewrite a parent method in its own way, which gives runtime polymorphism. Overriding is not possible without inheritance. So both reasons are right, and the answer is 'Both A & B'.
प्रश्न 10उत्तर + हल
वंशानुक्रम (Inheritance) की अवधारणा का प्रयोग किस भाषा में नहीं किया जाता है?
The concept of inheritance is not used in which language?
  1. AC++
  2. BJava
  3. CPython
  4. DC भाषाC Language

सही उत्तर / Answer: (D)

हल / Solution
inheritance एक OOP अवधारणा है, जिसमें एक class दूसरी class के गुण लेती है। इसके लिए भाषा में class होनी चाहिए। C++, Java और Python तीनों object-oriented भाषाएँ हैं और तीनों में inheritance होता है। C भाषा procedural है। उसमें class नहीं होती, सिर्फ़ structure और functions होते हैं। इसलिए C में inheritance की अवधारणा नहीं है और उत्तर C भाषा है।
Inheritance is an OOP concept in which one class takes the features of another class. For this, a language must have classes. C++, Java and Python are all object-oriented languages, and all three support inheritance. The C language is procedural. It has no classes, only structures and functions. So the concept of inheritance is not used in C, and the answer is option 4.
आगे के 20 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
App खोलिए
प्रश्न 11उत्तर app में
extends का उपयोग क्या है?
What is the use of extends?
  1. Aदूसरे पैकेज से क्लास को import करने के लिएTo import a class from another package
  2. Bदो क्लासों के बीच संबंध को अलग करने के लिएTo separate the relationship between two classes
  3. Cदो क्लासों के बीच संबंध बनाने के लिएTo create a relationship between two classes
  4. Dइनमें से कोई नहींNone of these
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 12उत्तर app में
"जावा कंस्ट्रक्टर ओवरलोडिंग" OOP के किस सिद्धांत का पालन करती है?
"Java Constructor Overloading" follows which principle of OOP?
  1. Aइनहेरिटेंस (Inheritance)Inheritance
  2. Bएनकैप्सुलेशन (Encapsulation)Encapsulation
  3. Cपॉलीमॉर्फ़िज़्म (Polymorphism)Polymorphism
  4. Dइनमें से कोई नहींNone of these
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 14उत्तर app में
जावा कंस्ट्रक्टर ___ के बिना एक मेथड की तरह होता है।
A Java constructor is like a method without ___.
  1. Aस्टेटमेंट (Statement)Statement
  2. Bरिटर्न टाइप (return type)return type
  3. Cआर्गुमेंट (Argument)Argument
  4. Dइनमें से कोई नहींNone of these
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 15उत्तर app में
क्लास के अंदर ही क्लास के सदस्य को कॉल/एक्सेस करने के लिए किस कीवर्ड का इस्तेमाल किया जाता है?
Which keyword is used to call/access a member of a class within the class?
  1. AThat
  2. BThese
  3. Cthis
  4. Dइनमें से कोई नहींNone of these
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 16उत्तर app में
पैरामीटराइज़्ड कंस्ट्रक्टर किसके द्वारा जोड़ा जाता है?
A parameterized constructor is added by ___?
  1. AकंपाइलरCompiler
  2. Bसी.पी.यू.C.P.U.
  3. Cयूज़र (प्रोग्रामर)User
  4. Dइनमें से कोई नहींNone of these
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 17उत्तर app में
डिफ़ॉल्ट कंस्ट्रक्टर को ___ भी कहा जाता है।
The default constructor is also called ___.
  1. Aपैरामीटराइज़्ड कंस्ट्रक्टरParameterized constructor
  2. Bनॉन-पैरामीटराइज़्ड (बिना पैरामीटर वाला) कंस्ट्रक्टरNon-parameterized constructor
  3. Cडिस्ट्रक्ट कंस्ट्रक्टरDestruct constructor
  4. Dइनमें से कोई नहींNone of these
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 18उत्तर app में
कंस्ट्रक्टर से संबंधित कथन:
(I) हर क्लास में कम से कम एक कंस्ट्रक्टर होना चाहिए।
(II) यदि यूज़र ने कंस्ट्रक्टर नहीं बनाया है तो क्लास में डिफ़ॉल्ट कंस्ट्रक्टर का उपयोग होता है।
Statements related to constructor:
(I) A class must have at least one constructor.
(II) If the constructor is not made by the user, then the default constructor is used in the class.
  1. Aकथन I ग़लत हैStatement I is wrong
  2. Bकथन II ग़लत हैStatement II is wrong
  3. Cकथन I और II दोनों सही हैंBoth statements I & II are right
  4. Dइनमें से कोई नहींNone of these
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 20उत्तर app में
निम्न में से कौन-सा डिफ़ॉल्ट कंस्ट्रक्टर का सबसे अच्छा वर्णन है?
Which of the following best describes the default constructor?
  1. Aजावा प्रोग्राम से अपने आप हटा दिया जाता हैRemoved by default from a Java program
  2. Bजावा प्रोग्राम में अपने आप (compiler द्वारा) जुड़ जाता हैAdded by default (by the compiler) in a Java program
  3. CA और B दोनोंBoth A & B
  4. Dइनमें से कोई नहींNone of these
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 23उत्तर app में
कंस्ट्रक्टर से संबंधित कथन:
(a) कंस्ट्रक्टर का नाम क्लास के नाम जैसा होता है।
(b) कंस्ट्रक्टर final और static नहीं होता है।
Statements related to constructor:
(a) The constructor name is the same as the class name.
(b) A constructor is not final and not static.
  1. Aकथन a ग़लत हैStatement a is wrong
  2. Bकेवल कथन a सही हैOnly statement a is right
  3. Cकथन a और b दोनों सही हैंStatements a & b are both right
  4. Dकोई नहींNone
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 24उत्तर app में
कंस्ट्रक्टर का उपयोग किसलिए होता है?
Which option gives the use of a constructor?
  1. Aडेटा को नष्ट करने के लिएTo destroy data
  2. Bऑब्जेक्ट और क्लास के डेटा सदस्यों को इनिशियलाइज़ करने के लिएTo initialize the object & class data members
  3. Cक्लास को इनिशियलाइज़ करने के लिएTo initialize the class
  4. Dकोई नहींNone
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 25उत्तर app में
निम्नलिखित में से कौन जावा में कंस्ट्रक्टर का सबसे अच्छा वर्णन है?
Which of the following best describes a constructor in Java?
  1. Aकोड का एक ब्लॉक (Block of code)Block of code
  2. Bएक विशेष प्रकार का मेथडA special type of method
  3. CA और B दोनोंBoth A & B
  4. Dकोई नहींNone
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 27उत्तर app में
निम्नलिखित में से कौन Java में object की सबसे अच्छी परिभाषा है?
Which of the following is the best definition of an object in Java?
  1. Aवास्तविक दुनिया की इकाई (real world entity)Real world entity
  2. Bरन टाइम इकाई (run time entity)Run time entity
  3. Cclass का instanceInstance of a class
  4. Dउपरोक्त सभीAll of the above
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 29उत्तर app में
निम्न में से कौन class का सबसे अच्छा वर्णन है?
Which of the following best describes a class?
  1. AData member का संग्रहCollection of data members
  2. Bयह एक blueprint हैIt is a blueprint
  3. Cयह structure की तरह हैIt is just like a structure
  4. Dउपरोक्त सभीAll of the above
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
OOPs Concept (Basic) के सभी 69 प्रश्न — उत्तर, हल और अभ्यास

FliQi Question Bank app में topic-वार अभ्यास, कठिनाई-स्तर और आपकी प्रगति।

  • पहला test मुफ़्त
  • हिंदी + English
  • जाँचे हुए उत्तर और हल

यह topic किन परीक्षाओं में आता है

Java के दूसरे topics

सभी topics