FliQi Education App Download
Basic Computer Instructor — Paper II · प्रश्न-बैंक

Basic Computer Instructor — Paper II — Java के प्रश्न

369 जाँचे हुए प्रश्न · 19 topics · परीक्षा में 2 प्रश्न

Topics

प्रश्न

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

भाषा
प्रश्न 1उत्तर + हल History & Introduction of Java
Java भाषा का आविष्कार किसने किया था?
Who invented the Java language?
  1. ADennis Ritchie
  2. BJames Gosling
  3. CLarry Page
  4. DSergey Brin

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

हल / Solution
Java का आविष्कार James Gosling ने Sun Microsystems में किया था। यह काम 1991 में Green project के रूप में शुरू हुआ और 1995 में भाषा Java नाम से सामने आई। Dennis Ritchie ने Bell Labs में C भाषा बनाई थी। Larry Page और Sergey Brin ने मिलकर Google की स्थापना की थी। इन तीनों का Java के आविष्कार से कोई संबंध नहीं है, इसलिए सही उत्तर James Gosling है।
Java was invented by James Gosling at Sun Microsystems. The work began in 1991 as the Green project, and the language came out under the name Java in 1995. Dennis Ritchie created the C language at Bell Labs. Larry Page and Sergey Brin together founded Google. None of these three had a role in inventing Java, so the correct answer is James Gosling.
प्रश्न 2उत्तर + हल OOPs Concept (Basic)
main मेथड को static किस कारण से होना चाहिए?
The main method should be static for which reason?
  1. Aताकि class loader उसे आसानी से एक्सेस कर सकेIt can be accessed easily by the class loader
  2. Bताकि हर मेथड या वेरिएबल बिना क्लास के उसे एक्सेस कर सकेIt can be accessed by every method or variable without class
  3. Cताकि उसे क्लास का कोई इंस्टेंस बनाए बिना चलाया जा सकेIt can be executed without creating any instance of the class
  4. Dउपरोक्त में से कोई नहींNone of the above

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

हल / Solution
program शुरू होते समय JVM के पास उस class का कोई object नहीं होता। static method class से जुड़ा होता है, इसलिए उसे object बनाए बिना सीधे ClassName.main() की तरह बुलाया जा सकता है। यही main() के static होने का असली कारण है। class loader का काम class को memory में लाना है, main को static बनाने से उसका लेना-देना नहीं। विकल्प 2 ग़लत है, क्योंकि static method भी class से ही जुड़ा रहता है।
When a program starts, the JVM has no object of the class yet. A static method belongs to the class, so it can be called directly, like ClassName.main(), without creating an object. That is the real reason main() is static. The class loader's job is only to load the class into memory; it is not the reason for static. Option 2 is wrong because a static method still belongs to its class.
प्रश्न 3उत्तर + हल History & Introduction of Java
Java किस प्रोग्रामिंग भाषा के आधार पर विकसित की गई है?
Java was developed on the basis of which programming language?
  1. AB
  2. BPascal
  3. CC++
  4. DD

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

हल / Solution
Java की syntax और object-oriented ढाँचा मुख्य रूप से C++ से लिया गया है। James Gosling चाहते थे कि C++ जानने वाले programmer इसे जल्दी सीख लें। पर pointer और multiple inheritance जैसी उलझनें इसमें से हटा दी गईं। Java की HotSpot JVM भी ज़्यादातर C++ में लिखी गई है। B एक पुरानी भाषा है जिससे आगे चलकर C बनी। Pascal का Java से सीधा संबंध नहीं है, और D तो Java के बाद आई।
Java takes its syntax and its object-oriented design mainly from C++. James Gosling wanted C++ programmers to learn it quickly. But confusing parts such as pointers and multiple inheritance of classes were removed. The HotSpot JVM that runs Java is also written mostly in C++. B is an old language that later led to C. Pascal has no direct link with Java, and D came after Java.
प्रश्न 4उत्तर + हल OOPs Concept (Basic)
कंस्ट्रक्टर का निहित (implicit) रिटर्न टाइप क्या है?
The implicit return type of a constructor is?
  1. AVoid
  2. Bउसी क्लास का ऑब्जेक्ट जिसमें वह परिभाषित हैA class object in which it is defined
  3. Cकोई रिटर्न टाइप नहीं होताThere is no return type
  4. Dइनमें से कोई नहींNone of these

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

हल / Solution
यहाँ ख़ास शब्द implicit यानी 'निहित' है। constructor के आगे कोई return type लिखा नहीं जाता, void भी नहीं। पर new ClassName() लिखने पर constructor उसी class का नया object तैयार करता है और उसका reference हमें मिलता है। इसलिए निहित रूप से उसका return उसी class का object माना जाता है। 'कोई return type नहीं' लिखे हुए (explicit) type की बात है, निहित की नहीं। void तो constructor पर लगता ही नहीं।
The key word here is implicit. No return type is written before a constructor, not even void. But when we write new ClassName(), the constructor sets up a new object of that class and we get its reference back. So, implicitly, its return is treated as an object of the class in which it is defined. 'No return type' describes the explicit, written type, not the implicit one. Void never applies to a constructor.
प्रश्न 5उत्तर + हल History & Introduction of Java
निम्न में से कौन Java कोड एडिटर नहीं है? (IA 2018)
Which of the following is not a Java code editor? (IA 2018)
  1. AMS Word
  2. BNetBeans
  3. CNotepad++
  4. DEditPlus

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

हल / Solution
MS Word एक word processor है। इसमें चिट्ठी, रिपोर्ट जैसे formatted दस्तावेज़ बनते हैं। यह फ़ाइल में formatting की छिपी जानकारी भी जोड़ता है, इसलिए इससे Java का सादा source code लिखना ठीक नहीं। NetBeans एक पूरा IDE है, जिसमें code लिखना, compile करना और debug करना एक ही जगह होता है। Notepad++ और EditPlus सादे text editor हैं, जिनमें Java code लिखकर .java फ़ाइल बनाई जा सकती है।
MS Word is a word processor. It is used to make formatted documents such as letters and reports. It also adds hidden formatting data to the file, so it is not suitable for writing plain Java source code. NetBeans is a full IDE where you can write, compile and debug code in one place. Notepad++ and EditPlus are plain text editors, so Java code can be typed in them and saved as a .java file.
प्रश्न 6उत्तर + हल OOPs Concept (Basic)
क्लास के सभी मेथड के उपयोग के लिए क्लास में घोषित किए गए चर (variable) क्या कहलाते हैं?
The variables declared in a class for the use of all methods of the class are called?
  1. Aलोकल वेरिएबल (Local variable)Local variable
  2. Bऑब्जेक्ट (Objects)Objects
  3. Cइंस्टेंस वेरिएबल (Instance variable)Instance variable
  4. Dइनमें से कोई नहींNone of these

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

हल / Solution
जो variable class के अंदर पर किसी method के बाहर declare होता है, उसे instance variable कहते हैं। वह हर object के साथ बनता है और उस class के सभी instance methods उसे इस्तेमाल कर सकते हैं। local variable किसी method या block के अंदर declare होता है और सिर्फ़ उसी method में चलता है, इसलिए वह सभी methods के लिए नहीं है। object ख़ुद variable नहीं, class का instance है।
A variable declared inside a class but outside every method is called an instance variable. It is created with each object, and all instance methods of that class can use it. A local variable is declared inside a method or block and works only inside that method, so it is not shared by all methods. An object is not a variable at all; it is an instance of a class. So the answer is instance variable.
प्रश्न 7उत्तर + हल History & Introduction of Java
Java का जनक (father of Java) किसे कहा जाता है?
Who is the father of Java?
  1. AJames Gosling
  2. BLinus Torvalds
  3. CTurner Lee
  4. DJames Drew

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

हल / Solution
James Gosling को Java का जनक कहा जाता है। उन्होंने 1991 में Sun Microsystems में Green Team के साथ इस भाषा पर काम शुरू किया। पहले इसका नाम Oak था, फिर 1995 में इसे Java नाम से जारी किया गया। Linus Torvalds ने Linux kernel बनाया था, Java नहीं। Turner Lee और James Drew का Java के विकास से कोई संबंध नहीं है, ये सिर्फ़ भटकाने वाले नाम हैं।
James Gosling is called the father of Java. In 1991 he started work on the language with the Green Team at Sun Microsystems. It was first named Oak and was released under the name Java in 1995. Linus Torvalds created the Linux kernel, not Java. Turner Lee and James Drew have no link with the making of Java; they are only distractor names added to confuse.
प्रश्न 8उत्तर + हल OOPs Concept (Basic)
कंस्ट्रक्टर के साथ किस मॉडिफ़ायर का उपयोग नहीं किया जा सकता?
Which modifier cannot be used with constructors?
  1. Apublic
  2. Bprivate
  3. Cstatic
  4. Dprotected

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

हल / Solution
constructor का काम नया object तैयार करना है, इसलिए वह हमेशा किसी object से जुड़ा होता है। static चीज़ें class से जुड़ी होती हैं, object से नहीं। इसलिए constructor को static बनाना ग़लत है और compiler error देता है। चारों access modifier constructor पर लग सकते हैं। public से हर class object बना सकती है, private से Singleton बनता है, और protected से subclass तक पहुँच रहती है। इसलिए उत्तर static है।
A constructor sets up a new object, so it always belongs to an object. Static members belong to the class, not to any object. So a static constructor makes no sense, and the compiler gives an error. All access modifiers can be used on constructors. With public any class can create the object, private is used for Singleton, and protected gives access to subclasses. So the answer is static.
प्रश्न 9उत्तर + हल OOPs Concept (Basic)
यदि कंस्ट्रक्टर के साथ रिटर्न टाइप लिख दिया जाए तो क्या होगा?
What would be the behavior if the constructor has a return type?
  1. Aकंपाइलेशन त्रुटिCompilation error
  2. Bरनटाइम त्रुटिRuntime error
  3. Cप्रोग्राम कंपाइल होकर सफलतापूर्वक चलता हैCompiles and runs successfully
  4. Dकेवल String रिटर्न टाइप की अनुमति हैOnly String return type is allowed

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

हल / Solution
constructor का कोई return type नहीं होता, void भी नहीं। अगर class के नाम वाले block के आगे void या int लिख दें, जैसे void Test() { }, तो Java उसे constructor नहीं मानता। वह एक साधारण method बन जाता है, जिसका नाम class जैसा है। यह नियम के अनुसार सही है, इसलिए program compile भी होता है और चलता भी है। compiler तब default constructor ख़ुद जोड़ देता है। String वाली कोई ख़ास छूट नहीं है।
A constructor has no return type, not even void. If you write void or int before a block named like the class, such as void Test() { }, Java does not treat it as a constructor. It becomes an ordinary method that happens to share the class name. This is legal, so the program compiles and runs without any error. The compiler then adds the default constructor by itself. There is no special rule for String.
प्रश्न 10उत्तर + हल OOPs Concept (Basic)
निजी (private) कंस्ट्रक्टर के बारे में क्या सही है?
What is true about a private constructor?
  1. Aprivate कंस्ट्रक्टर यह सुनिश्चित करता है कि किसी भी समय क्लास का केवल एक ही इंस्टेंस मौजूद रहेA private constructor ensures only one instance of a class exists at any point of time
  2. Bprivate कंस्ट्रक्टर यह सुनिश्चित करता है कि किसी भी समय क्लास के कई इंस्टेंस मौजूद रहेंA private constructor ensures multiple instances of a class exist at any point of time
  3. Cprivate कंस्ट्रक्टर दूसरी क्लासों में ऑब्जेक्ट बनाने देता हैA private constructor allows creating objects in other classes
  4. Dउपरोक्त में से कोई नहींNone of the above

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

हल / Solution
constructor को private बनाने पर कोई दूसरी class new लगाकर उसका object नहीं बना सकती। object बनाने का काम class के अंदर ही रहता है। इसी का उपयोग Singleton pattern में होता है। वहाँ class एक static method से हमेशा वही एक object लौटाती है, यानी एक समय में एक ही instance रहता है। कई instance बनवाना इसका उलटा है। दूसरी class में object बनाना private होने से रुक जाता है, इसलिए विकल्प 3 भी ग़लत है।
When a constructor is private, no other class can use new to create its object. Object creation stays inside the class itself. This is used in the Singleton pattern, where a static method of the class always returns the same single object, so only one instance exists at a time. Creating many instances is the opposite of this. Creating objects from other classes is blocked by private, so option 3 is also wrong.
आगे के 10 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
App खोलिए
प्रश्न 11उत्तर app में OOPs Concept (Basic)
कंस्ट्रक्टर वाले नीचे दिए गए जावा प्रोग्राम का आउटपुट क्या है?
public class Constructor2
{
  int count=10;
  Constructor2(int count)
  {
    System.out.println("Count=" + count);
  }
 
  public static void main(String[] args)
  {
    Constructor2 con = new Constructor2();
  }
}
What is the output of the Java program below with constructors?
public class Constructor2
{
  int count=10;
  Constructor2(int count)
  {
    System.out.println("Count=" + count);
  }
 
  public static void main(String[] args)
  {
    Constructor2 con = new Constructor2();
  }
}
  1. ACount=0
  2. BCount=10
  3. Cकंपाइलर त्रुटि (Compiler error)Compiler error
  4. Dउपरोक्त में से कोई नहींNone of the above
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 12उत्तर app में OOPs Concept (Basic)
कंपाइलर किसी क्लास में डिफ़ॉल्ट नो-आर्गुमेंट कंस्ट्रक्टर तब जोड़ता है, जब वह क्लास ___।
The compiler adds a default no-argument constructor to a class if it ___.
  1. Aकोई भी कंस्ट्रक्टर परिभाषित नहीं करतीdoes not define a constructor at all
  2. Bआर्गुमेंट वाला कम से कम एक कंस्ट्रक्टर परिभाषित करती हैdefines at least one constructor with arguments
  3. Cआर्गुमेंट वाले एक से अधिक कंस्ट्रक्टर परिभाषित करती हैdefines more than one constructor with arguments
  4. Dउपरोक्त में से कोई नहींnone of the above
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 13उत्तर app में OOPs Concept (Basic)
जावा में, बिना पैरामीटर (बिना तर्क) वाले कंस्ट्रक्टर को ___ कंस्ट्रक्टर कहा जाता है।
In Java, a constructor with no parameters or no arguments is called a ___ constructor.
  1. Aडिफ़ॉल्ट कंस्ट्रक्टर (Default constructor)Default constructor
  2. Bयूज़र-डिफ़ाइंड कंस्ट्रक्टर (User-defined constructor)User-defined constructor
  3. Cबेसिक कंस्ट्रक्टर (Basic constructor)Basic constructor
  4. Dउपरोक्त में से कोई नहींNone of the above
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 14उत्तर app में OOPs Concept (Basic)
Byte code किसका परिणाम है?
Byte code is the result of?
  1. AClass फ़ाइल को interpret करनाInterpreting a class file
  2. BClass फ़ाइल को compile करनाCompiling a class file
  3. CJava फ़ाइल को interpret करनाInterpreting a Java file
  4. DJava फ़ाइल को compile करनाCompiling a Java file
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 15उत्तर app में OOPs Concept (Basic)
Java constructor का उद्देश्य ___ है।
The purpose of a Java constructor is ___.
  1. Aobject को आरंभिक मान देना (initialization)Initializing an object
  2. Bcustom code लिखनाWriting custom code
  3. Cदूसरे object को input के रूप में लेनाAccepting other objects as inputs
  4. Dउपरोक्त सभीAll the above
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 18उत्तर app में OOPs Concept (Basic)
नीचे दी गई class का object बनाने का सही तरीका चुनिए।
class Table
Choose the correct way of creating an object of the class below.
class Table
  1. ATable t = new Table;
  2. BTable t = new Table();
  3. CTable() t = new Table();
  4. Dइनमें से कोई नहींNone of the above
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
Basic Computer Instructor — Paper II Java — topic-वार पूरा अभ्यासFliQi Question Bank app में