FliQi Education App Download
RPSC Programmer — Paper II · प्रश्न-बैंक

RPSC Programmer — Paper II — Programmer Java के प्रश्न

1,298 जाँचे हुए प्रश्न · 53 topics · परीक्षा में 50 प्रश्न

Topics

प्रश्न

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

भाषा
प्रश्न 1उत्तर + हल OOPs Concept - Constructors
निम्नलिखित class परिभाषा पर विचार कीजिए:

public class MyClass {

    private int value;

    public MyClass() {

        this(0);

    }

    public MyClass(int value) {

        this.value = value;

    }

    public int getValue() {

        return value;

    }

}

नीचे दिए कोड का आउटपुट क्या होगा?

MyClass obj = new MyClass();

System.out.println(obj.getValue());
Consider the following class definition:

public class MyClass {

    private int value;

    public MyClass() {

        this(0);

    }

    public MyClass(int value) {

        this.value = value;

    }

    public int getValue() {

        return value;

    }

}

What is the output of the following code snippet?

MyClass obj = new MyClass();

System.out.println(obj.getValue());
  1. A0
  2. B1
  3. Cकम्पाइलेशन त्रुटिCompilation error
  4. Dरनटाइम त्रुटिRuntime error

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

हल / Solution
new MyClass() लिखते ही बिना पैरामीटर वाला कन्स्ट्रक्टर चलता है। उसके भीतर this(0) लिखा है, यानी वह उसी class के दूसरे कन्स्ट्रक्टर को शून्य देकर बुला देता है। वहाँ this.value = value चलने से फ़ील्ड में शून्य बैठ जाता है। इसलिए getValue शून्य ही लौटाएगी और आउटपुट शून्य आएगा। यह कोड पूरी तरह वैध है, इसलिए न कम्पाइलेशन त्रुटि आती है न रनटाइम त्रुटि, और एक कहीं से नहीं आता।
Writing new MyClass() runs the no-argument constructor. Inside it sits this(0), which hands control to the other constructor of the same class with zero as the argument. There this.value = value puts zero into the field. So getValue returns zero and the program prints 0. The code is perfectly legal, so neither a compilation error nor a runtime error appears, and the value 1 never enters the picture.
प्रश्न 2उत्तर + हल java.io Package
Java में keyboard से input पढ़ने के लिए Scanner object बनाने में कौन-सा constructor प्रयोग होता है?
Which of the following constructors is used to create a Scanner object to read input from the keyboard in Java?
  1. AScanner(System.in)
  2. BScanner(File file)
  3. CScanner(Reader reader)
  4. DScanner(String source)

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

हल / Solution
keyboard से input पढ़ने के लिए Scanner sc = new Scanner(System.in); लिखा जाता है। System.in एक InputStream है, जो standard input यानी keyboard से जुड़ा होता है। Scanner(File file) किसी file से पढ़ता है। Scanner(String source) दी गई String को ही पढ़कर tokens बनाता है। Reader वाला रूप किसी character stream से पढ़ता है, keyboard से सीधे नहीं। इसलिए keyboard input के लिए Scanner(System.in) सही है।
To read keyboard input we write Scanner sc = new Scanner(System.in);. System.in is an InputStream connected to standard input, which is normally the keyboard. Scanner(File file) reads from a file, and Scanner(String source) scans the given String itself and breaks it into tokens. The Reader form reads from a character stream that you supply, not directly from the keyboard. So Scanner(System.in) is the standard constructor for keyboard input, and option 1 is correct.
प्रश्न 3उत्तर + हल Operator
जावा में राइट शिफ्ट (>>) किसके बराबर है?
Right Shift (>>) in Java is equivalent to?
  1. Aसंख्या को 2 से गुणा करनाMultiplying the number by 2
  2. Bसंख्या को 2 से भाग देनाDividing the number by 2
  3. Cसंख्या में से 2 घटानाSubtracting the number by 2
  4. Dसंख्या में 2 जोड़नाAdding the number by 2

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

हल / Solution
बिट एक जगह दाएँ खिसकाने पर हर बिट का स्थानीय मान आधा हो जाता है। इसलिए एक बार दाएँ खिसकाना 2 से भाग देने के बराबर है, और n जगह खिसकाना 2 की n घात से भाग देने के बराबर। जैसे 20 को दो जगह खिसकाने पर 5 मिलता है। भाग में दशमलव नहीं बचता, नीचे की पूर्ण संख्या मिलती है। गुणा बाएँ शिफ्ट से होता है, इसलिए विकल्प 1 ग़लत है।
Moving the bits one place to the right halves the place value of every bit. So one right shift is the same as dividing by 2, and shifting n places is the same as dividing by 2 raised to n. For example, shifting 20 by two places gives 5. No fraction survives; you get the whole number below. Multiplying is what a left shift does, so option 1 is wrong, and options 3 and 4 are unrelated.
प्रश्न 4उत्तर + हल OOPs Concepts - Relationships in java
Java में किसी class को subclass बनने से रोकने के लिए कौन-सा keyword लगाया जाता है?
Which keyword is used to prevent a class from being subclassed in Java?
  1. Aabstract
  2. Bfinal
  3. Cstatic
  4. Dsealed

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

हल / Solution
final class को कोई extend नहीं कर सकता — इसीलिए String class final है, ताकि उसका बर्ताव बदला न जा सके। abstract तो उलटा है, वह class को extend कराने के लिए ही बनती है। static का काम nested class या member को class के स्तर पर बाँधना है, वंशानुक्रम रोकना नहीं। sealed सिर्फ़ चुनी हुई classes तक विरासत सीमित करता है, पूरी तरह रोकता नहीं। इसलिए उत्तर final है।
A final class cannot be extended by anyone, which is why the String class is final, so its behaviour stays safe. An abstract class is the opposite, since it exists to be extended. The static keyword ties a nested class or a member to the class level and never blocks inheritance. A sealed class only limits inheritance to chosen classes instead of stopping it. So final is the answer.
प्रश्न 5उत्तर + हल OOPs Concepts - Inheritance
एक interface से दूसरे interface के बीच inheritance लागू करने के लिए निम्न में से किसका उपयोग किया जाता है?
Which of the following is used for implementing inheritance between interface to interface?
  1. Ainherited
  2. Busing
  3. Cextends
  4. Dimplements

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

हल / Solution
interface जब किसी दूसरे interface के तरीक़े लेता है तो वहाँ extends ही लगता है, जैसे interface B extends A। implements सिर्फ़ तब आता है जब कोई class किसी interface का काम पूरा करने का वादा करती है। ध्यान रखिए, एक interface कई interface को एक साथ extends कर सकता है, जो class के लिए संभव नहीं। inherited और using Java के कीवर्ड नहीं हैं, इसलिए पहले दो विकल्प तो शुरू में ही बाहर हो जाते हैं।
When one interface takes the methods of another interface, the word extends is used, as in interface B extends A. The keyword implements appears only when a class promises to supply the body of an interface. Note that a single interface may extend several interfaces at once, which a class cannot do. Neither inherited nor using is a Java keyword, so the first two options drop out straight away.
प्रश्न 6उत्तर + हल OOPs Concepts - Polymorphism
मेथड ओवरलोडिंग कब निर्धारित की जाती है?
When is method overloading determined?
  1. Aरन टाइम परAt run time
  2. Bकम्पाइल टाइम परAt compile time
  3. Cकोडिंग के समयAt coding time
  4. Dएक्ज़ीक्यूशन के समयAt execution time

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

हल / Solution
ओवरलोडिंग में एक ही नाम की कई method होती हैं और उनके पैरामीटर अलग-अलग होते हैं। कौन सी method चलेगी, यह compiler call में दिए गए तर्कों की संख्या और प्रकार देखकर पहले ही तय कर देता है। इसीलिए इसे compile time polymorphism या early binding कहते हैं। रन टाइम और एक्ज़ीक्यूशन टाइम एक ही बात है और वह overriding पर लागू होती है, ओवरलोडिंग पर नहीं। कोडिंग के समय तो सिर्फ़ प्रोग्राम लिखा जाता है, कोई फ़ैसला नहीं होता।
In overloading there are several methods with one name and different parameter lists. The compiler looks at the number and the types of the arguments and fixes the right method before the program runs. That is why overloading is called compile time polymorphism or early binding. Run time and execution time mean the same thing, and that applies to overriding, not to overloading. At coding time the programmer only writes the program, so no decision is taken there.
प्रश्न 7उत्तर + हल OOPs Concept - Object in java
जावा में class और object के बीच क्या संबंध है?
What is the relationship between a class and an object in Java?
  1. Aobject किसी class का instance होता है।An object is an instance of a class.
  2. Bclass किसी object की instance होती है।A class is an instance of an object.
  3. Cclass और object एक ही चीज़ हैं।A class and an object are the same thing.
  4. Dobject class से inherit करता है।An object inherits from a class.

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

हल / Solution
class एक साँचा है और object उस साँचे से बनी असली इकाई। इसीलिए कहा जाता है कि object अपनी class का instance है, और पहला विकल्प सही है। दूसरा विकल्प रिश्ते को उलटा कर देता है। तीसरा दोनों को एक ही चीज़ बता देता है, जबकि class लिखने के समय की परिभाषा है और object चलते समय की चीज़। चौथे विकल्प वाला inherit का रिश्ता दो class के बीच होता है, class और object के बीच नहीं।
A class is a mould and an object is the real unit made from it. That is why we say an object is an instance of its class, so option 1 is correct. Option 2 turns the relation upside down. Option 3 treats the two as one thing, though a class is a definition written in advance while an object exists at runtime. The inheritance of option 4 holds between two classes, not between a class and an object.
प्रश्न 8उत्तर + हल OOPs Concepts - Data Hiding(Abstraction and Encapsulation)
encapsulation की अवधारणा का उपयोग करने से डेटा की सुरक्षा कैसी रहती है?
Using the concept of encapsulation, security of the data is ___________
  1. Aकुछ हद तक सुनिश्चितEnsured to some extent
  2. Bपूरी तरह सुनिश्चितPurely ensured
  3. Cसुनिश्चित नहींNot ensured
  4. Dबहुत कमVery low

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

हल / Solution
encapsulation fields को private करके सीधी पहुँच रोक देता है, इसलिए सुरक्षा बढ़ती है। पर यह पूरी सुरक्षा नहीं है — reflection से private field तक पहुँचा जा सकता है, और लापरवाही से लिखा setter ख़ुद ही रास्ता खोल देता है। इसलिए सही बात यही है कि सुरक्षा कुछ हद तक मिलती है, और पहला विकल्प ठीक बैठता है। दूसरा विकल्प ज़्यादा दावा करता है, तीसरा और चौथा फ़ायदा ही नकार देते हैं।
Encapsulation makes the fields private and blocks direct access, so security does improve. Yet the protection is not complete: reflection can reach a private field, and a carelessly written setter opens a door by itself. So the honest answer is that security is ensured to some extent, which is option 1. Option 2 claims too much, while options 3 and 4 deny a benefit that clearly exists.
प्रश्न 9उत्तर + हल History & Introduction of Java
Java प्रोग्रामों को compile करने के लिए ...... को लिखा जाता है।
To compile Java programs, ...... is written.
  1. A.java
  2. B.javac
  3. C.Cjava
  4. D.jawa

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

हल / Solution
जावा का प्रोग्राम .java नाम वाली फ़ाइल में सहेजा जाता है, पर उसे compile करने के लिए javac चलाया जाता है। यह औज़ार JDK के साथ आता है और source code को bytecode में बदलकर .class फ़ाइल बना देता है। पहला विकल्प सिर्फ़ source फ़ाइल का नाम बताता है, compiler का नहीं। बाक़ी दो रूप .Cjava और .jawa जावा में होते ही नहीं, इसलिए वे ग़लत हैं।
A Java program is saved in a file with the .java extension, but to compile it you run javac, the compiler that comes with the JDK. It turns the source code into bytecode and stores it in a .class file. The first choice names the source file, not the compiler. The last two spellings, .Cjava and .jawa, do not exist in Java at all.
प्रश्न 10उत्तर + हल OOPs Concepts - Interface
क्या जावा में किसी interface में constructor हो सकता है?
Can an interface contain a constructor in Java?
  1. AहाँYes
  2. BनहींNo
  3. CशायदMaybe
  4. Dइनमें से कोई नहींNone

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

हल / Solution
constructor का काम object बनने के समय उसे तैयार करना है। interface का object कभी बनता ही नहीं, इसलिए वहाँ constructor की ज़रूरत नहीं और जावा उसे रखने भी नहीं देता। लिखने पर compile के समय ही ग़लती मिल जाती है। इसलिए सही उत्तर नहीं है, यानी दूसरा विकल्प। पहला विकल्प हाँ कहता है, जो ग़लत है। यहाँ बीच का कोई रास्ता नहीं है, नियम साफ़ है, इसलिए तीसरा और चौथा विकल्प भी नहीं चलते।
A constructor exists to set up an object at the moment it is created. An interface is never instantiated, so it needs no constructor and Java does not allow one. If you write it, the error appears at compile time itself. That is why the answer is No, which is option 2. Option 1 says yes, which is wrong. There is no middle ground here, the rule is clear, so maybe and none do not work either.
आगे के 10 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
App खोलिए
प्रश्न 11उत्तर app में OOPs Concepts - Containers in Java (Class, Abstract Class, Interface)
class की सबसे ख़ास विशेषता क्या है?
What is the most striking feature of a class?
  1. Adata encapsulationData encapsulation
  2. Bएक ही प्रकार के object का संग्रहCollection of objects of similar type
  3. CinheritanceInheritance
  4. Dउपरोक्त सभीAll of the above
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 12उत्तर app में Multithreading
Java में sleep() विधि का काम क्या है?
What is the purpose of the sleep() method in Java?
  1. Aयह thread के चलने को तय समय के लिए रोक देती है।It suspends the thread's execution for a specified amount of time.
  2. Bयह किसी दूसरे thread की सूचना का इंतज़ार करती है।It waits for a notification from another thread.
  3. Cयह object पर लगा lock छोड़ देती है।It releases the lock on an object.
  4. Dयह thread को समाप्त कर देती है।It terminates the thread.
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 13उत्तर app में OOPs Concept - Constructors
निम्नलिखित class परिभाषा पर विचार कीजिए:

public class MyClass {

    private int value;

    public MyClass() {

        this.value = 10;

    }

    public MyClass(int value) {

        this.value = value;

    }

    public int getValue() {

        return value;

    }

}

MyClass class में कितने कन्स्ट्रक्टर हैं?
Consider the following class definition:

public class MyClass {

    private int value;

    public MyClass() {

        this.value = 10;

    }

    public MyClass(int value) {

        this.value = value;

    }

    public int getValue() {

        return value;

    }

}

How many constructors does the MyClass class have?
  1. A0
  2. B1
  3. C2
  4. D3
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 14उत्तर app में java.io Package
Java में BufferedReader से characters पढ़कर उन्हें character array में रखने के लिए कौन-सी method प्रयोग होती है?
Which method is used to read characters from a BufferedReader and store them into a character array in Java?
  1. Aread(char[] cbuf)
  2. BreadChar()
  3. Cread()
  4. DreadByte()
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 15उत्तर app में Operator
जावा में लेफ्ट शिफ्ट (<<) किसके बराबर है?
Left Shift (<<) in Java is equivalent to?
  1. Aसंख्या में से 2 घटानाSubtracting the number by 2
  2. Bसंख्या को 2 से भाग देनाDividing the number by 2
  3. Cसंख्या को 2 से गुणा करनाMultiplying the number by 2
  4. Dसंख्या में 2 जोड़नाAdding the number by 2
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 16उत्तर app में OOPs Concepts - Relationships in java
Java में superclass-subclass संबंध का महत्व क्या है?
In Java, what is the significance of the superclass-subclass relationship?
  1. Asubclass, superclass के private members तक पहुँच सकती है।Subclasses can access private members of the superclass.
  2. Bsuperclass, subclass के protected members तक पहुँच सकती है।Superclasses can access protected members of the subclass.
  3. Csubclass को superclass के members विरासत में मिलते हैं।Subclasses inherit members from the superclass.
  4. Dsuperclass अपने आप subclass के बताए interfaces लागू कर देती है।Superclasses automatically implement interfaces defined by subclasses.
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 17उत्तर app में OOPs Concepts - Inheritance
interface के माध्यम से inheritance लागू करने के लिए निम्न में से किसका उपयोग किया जाता है?
Which of the following is used for implementing inheritance through an interface?
  1. Ainherited
  2. Busing
  3. Cextends
  4. Dimplements
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 18उत्तर app में OOPs Concepts - Polymorphism
निम्नलिखित में से कौन सा जावा में polymorphism का प्रकार है?
Which of the following is a type of polymorphism in Java?
  1. Aकम्पाइल टाइम पॉलीमॉर्फिज़्मCompile time polymorphism
  2. Bअनुक्रमिक पॉलीमॉर्फिज़्मSequential polymorphism
  3. Cमल्टीपल पॉलीमॉर्फिज़्मMultiple polymorphism
  4. Dमल्टीलेवल पॉलीमॉर्फिज़्मMultilevel polymorphism
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 19उत्तर app में OOPs Concept - Object in java
निम्नलिखित में से कौन-सा जावा में object बनाने का वैध तरीक़ा नहीं है?
Which of the following is NOT a valid way to create an object in Java?
  1. AMyClass obj = new MyClass();
  2. Bobj = new MyClass();
  3. Cnew obj = MyClass();
  4. DMyClass obj = new MyClass(10);
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 20उत्तर app में OOPs Concepts - Data Hiding(Abstraction and Encapsulation)
यदि कोई code में encapsulation की अवधारणा का उपयोग कर रहा है, तो निम्नलिखित में से कौन सी बात सही है?
Which among the following concept is correct if a user using the concept of encapsulation in a code?
  1. Acode बदलना अतिरिक्त बोझ बन सकता हैThe modification of the code can be additional overhead
  2. Bmember functions से data members का data type बदला जा सकता हैMember functions can be used for modifying the data type of data members
  3. Cdata member का data type बदला ही नहीं जा सकताThe data type of data member cannot be modified.
  4. Ddata member का data type बाक़ी code छेड़े बिना आसानी से बदला जा सकता हैThe data type of the data member can be easily modified without modifying any other code
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
RPSC Programmer — Paper II Programmer Java — topic-वार पूरा अभ्यासFliQi Question Bank app में