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

Identifiers of Java — प्रश्न और उत्तर

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

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

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

भाषा
प्रश्न 1उत्तर + हल
«int System=10;» के बाद उसी program में System को class के रूप में इस्तेमाल करना हो तो क्या करना होगा?
After 'int System=10;', what must be done to use System as a class later in the same program?
  1. ASystem को दोबारा declare करना होगाSystem must be declared again
  2. Bउसे class में नहीं बदला जा सकताIt cannot be turned back into a class
  3. Cउसका पूरी तरह योग्य नाम लिखना होगा — java.lang.SystemIts fully qualified name must be written — java.lang.System
  4. Dprogram को दो file में बाँटना होगाThe program must be split into two files

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

हल / Solution
पाठ कहता है कि System को int variable बना लेने पर उसे शेष program में उसी रूप में इस्तेमाल करना होगा, और यदि class के रूप में चाहिए तो उसकी पूर्णतः योग्यता लिखनी होगी। उदाहरण में «java.lang.System.out.println(System);» चलता है जबकि सीधा «System.out.println(System);» पर compilation error मिलती है। package के नाम के साथ class का नाम बताना ही Fully Qualified Name कहलाता है।
The text says that once System has been made an int variable it must be used in that role through the remaining program, and if it is needed as a class then its fully qualified form must be written. In the example 'java.lang.System.out.println(System);' works, while a plain 'System.out.println(System);' gives a compilation error. Naming a class together with its package is what is called a Fully Qualified Name.
प्रश्न 2उत्तर + हल
Java में predefined class और interface के नाम identifier के रूप में इस्तेमाल किए जा सकते हैं?
In Java, can predefined class and interface names be used as identifiers?
  1. Aनहीं, वे reserved हैंNo, they are reserved
  2. Bहाँ, किए जा सकते हैंYes, they can be
  3. Cहाँ, पर सिर्फ़ method के नाम मेंYes, but only in a method's name
  4. Dनहीं, compiler रोक देता हैNo, the compiler stops it

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

हल / Solution
मद 8 कहती है कि Java application में सभी predefined class और interface के नाम identifier के रूप में इस्तेमाल किए जा सकते हैं — पाठ के उदाहरण «int Exception=10;» और «String String="String";» दोनों बिना error चलते हैं। keyword के साथ यह छूट नहीं है(मद 4), क्योंकि class का नाम reserved word नहीं होता, बस library में पहले से मौजूद होता है।
Point 8 says that in a Java application all predefined class and interface names may be used as identifiers — the text's examples 'int Exception=10;' and 'String String="String";' both run without error. This freedom does not extend to a keyword (point 4), because a class name is not a reserved word but merely a name already present in the library.
प्रश्न 3उत्तर + हल
किताब के अनुसार इनमें से कौन-सा नाम recommended है?
According to the book, which of these names is recommended?
  1. AString xxx="abc123";
  2. BString permanentemployeeaddress="Jai";
  3. Cint a1=10;
  4. DString accNo="abc123";

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

हल / Solution
मद 9 कहती है कि अर्थ बताने वाले नाम देने की सिफ़ारिश है — «xxx» not recommended और «accNo» recommended। मद 10 लम्बाई लगभग 10 चिह्न तक रखने की सलाह देती है, इसलिए «permanentemployeeaddress» भी not recommended है। ध्यान रहे ये सिफ़ारिशें हैं, नियम नहीं — चारों नाम वैध हैं और चारों पर compiler कोई आपत्ति नहीं करता, फ़र्क़ सिर्फ़ पढ़ने वाले के लिए है।
Point 9 recommends giving names that convey meaning — «xxx» is not recommended while «accNo» is. Point 10 advises keeping the length to about 10 symbols, so «permanentemployeeaddress» is not recommended either. Note that these are recommendations and not rules — all four names are valid and the compiler objects to none of them; the difference matters only to whoever reads the code.
प्रश्न 4उत्तर + हल
«int 9eno=999;» अवैध क्यों है?
Why is 'int 9eno=999;' invalid?
  1. A9 अनुमत वर्ण नहीं है9 is not a permitted character
  2. Bनाम तीन अक्षर से छोटा हैThe name is shorter than three characters
  3. Ceno एक keyword हैeno is a keyword
  4. Didentifier अंक से शुरू नहीं हो सकताAn identifier cannot begin with a digit

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

हल / Solution
अंक identifier में अनुमत हैं — «int eno=111;» और «String emp9No="E-9999";» दोनों वैध हैं। रोक सिर्फ़ शुरुआत पर है: मद 7 के अनुसार identifier अंक से शुरू नहीं हो सकता, इसलिए 9eno अवैध है। नाम तीन अक्षर से छोटा होना कोई दोष नहीं, «eno» keyword नहीं है, और लम्बाई पर तो कोई रोक ही नहीं — सो बाक़ी तीनों कारण ग़लत हैं।
Digits are permitted inside an identifier — both «int eno=111;» and «String emp9No="E-9999";» are valid. The restriction applies only to the beginning: by point 7 an identifier cannot start with a digit, so 9eno is invalid. A name being shorter than three characters is no fault, «eno» is not a keyword, and there is no restriction on length at all — so the other three reasons are wrong.
प्रश्न 5उत्तर + हल
Java में identifier किसे दिया जाता है?
In Java, an identifier is assigned to?
  1. Aसिर्फ़ variable कोOnly a variable
  2. Bvariable, method, class और interface — सबकोVariables, methods, classes and interfaces — all of them
  3. Cसिर्फ़ method कोOnly a method
  4. Dसिर्फ़ class कोOnly a class

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

हल / Solution
पाठ की पहली पंक्ति यही कहती है — identifier वह नाम है जो variables, methods, classes, abstract classes और interfaces जैसे programming element को दिया जाता है। सो यह सिर्फ़ variable का नाम नहीं है, और इसीलिए नामों के सारे नियम method तथा class पर भी उतने ही लागू होते हैं — जैसे «for Name()» method का नाम भी space की वजह से अवैध हो जाता है।
The opening line of the text says exactly this — an identifier is the name assigned to programming elements such as variables, methods, classes, abstract classes and interfaces. So it is not merely a variable's name, and that is why every naming rule applies just as much to methods and classes — the method name «for Name()», for instance, is invalid for the same reason of the space inside it.
प्रश्न 6उत्तर + हल
दिए गए code के बारे में क्या सही है?

class A {

    int i=10;

    void m1() {

        long i=30;

    }

}
What is true about the given code?

class A {

    int i=10;

    void m1() {

        long i=30;

    }

}
  1. Aदोनों i टकराएँगे, error आएगीThe two i's clash and an error occurs
  2. Bदूसरा i पहले वाले का मान बदल देगाThe second i overwrites the value of the first
  3. Cकोई error नहीं — दोनों i अलग-अलग scope में हैंNo error — the two i's are in different scopes
  4. Dmethod के अंदर कोई नाम दोहराया नहीं जा सकताNo name may be repeated inside a method

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

हल / Solution
मद 6 कहती है कि एक ही scope में identifier दोहराया नहीं जा सकता, पर दो अलग-अलग scope में वही नाम चल जाता है। यहाँ एक i class स्तर पर है और दूसरा method के अंदर local, सो कोई error नहीं। पाठ के उदाहरण में «short i=20;» पर error आती है क्योंकि वह उसी class स्तर पर दूसरा i है, जबकि method के अंदर «long i=30;» पर «No Error» लिखा है।
Point 6 says an identifier cannot be repeated within the same scope, but the same name works in two different scopes. Here one i is at class level and the other is local inside the method, so there is no error. In the text's example «short i=20;» does give an error, because that is a second i at the same class level, whereas «long i=30;» inside the method is marked «No Error».
प्रश्न 7उत्तर + हल
दिए गए code के बारे में क्या सही है?

class Test{

    int number=10;

    int Number=20;

    int NUMBER=30;

}
What is true about the given code?

class Test{

    int number=10;

    int Number=20;

    int NUMBER=30;

}
  1. Aतीनों एक ही variable हैंAll three are the same variable
  2. Bदूसरी पंक्ति पर error आएगीAn error occurs on the second line
  3. Cतीनों अलग-अलग variable हैंAll three are different variables
  4. Dतीसरी पंक्ति पर error आएगीAn error occurs on the third line

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

हल / Solution
Java identifier case sensitive होते हैं और पूरी Java भाषा ही case-sensitive मानी जाती है, यह मद 3 है। इसलिए number, Number और NUMBER तीन अलग नाम हैं और तीनों एक ही class में साथ रह सकते हैं — पाठ का उदाहरण इसमें NuMbEr भी जोड़ता है, यानी चार अलग variable। इसी वजह से «Int» keyword नहीं होता जबकि «int» होता है, और «True» का कोई अर्थ नहीं।
Java identifiers are case sensitive, and the Java language as a whole is regarded as case-sensitive; this is point 3. So number, Number and NUMBER are three different names and all three can sit together in one class — the text's example adds NuMbEr to them, making four distinct variables. This is also why «Int» is not a keyword while «int» is, and why «True» means nothing.
प्रश्न 8उत्तर + हल
package के नाम के साथ class या interface का नाम बताने को क्या कहा जाता है?
Specifying a class or interface name along with its package name is called?
  1. AShort Name
  2. BFully Qualified Name
  3. CReserved Name
  4. DRecommended Name

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

हल / Solution
पाठ का Note यही बताता है — package name के साथ class name और interface name बताना Fully Qualified Name कहलाता है, जैसे java.io.BufferedReader और java.util.ArrayList। इसका काम तब दिखता है जब class का नाम identifier बन चुका हो: System को int variable बना लेने पर भी «java.lang.System.out.println» चल जाता है, क्योंकि वहाँ पूरा पता दिया गया है और compiler को भ्रम नहीं रहता।
The text's Note states this — specifying a class name or interface name together with the package name is called a Fully Qualified Name, as in java.io.BufferedReader and java.util.ArrayList. Its use shows when a class name has already become an identifier: even after System is made an int variable, «java.lang.System.out.println» still works, because the full address leaves the compiler in no doubt.
प्रश्न 9उत्तर + हल
छपे अध्याय की मद 11 के अनुसार, एक ही identifier में कई शब्द हों तो उन्हें किस चिह्न से अलग करने की सिफ़ारिश है?
By point 11 of the printed chapter, which symbol is recommended for separating several words inside one identifier?
  1. A_ (underscore)
  2. B- (hyphen)
  3. C. (dot)
  4. Dकोई चिह्न नहीं, सब जोड़कर लिखिएNo symbol — write them all joined

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

हल / Solution
मद 11 साफ़ कहती है कि एक ही identifier में कई शब्द हों तो उन्हें _ जैसे चिह्न से अलग करने की सिफ़ारिश है, और उसका उदाहरण «perm_Emp_Addr» को recommended तथा «permEmpAddr» को not recommended बताता है। - और . तो अनुमत चिह्न ही नहीं — मद 2 के अनुसार _ और $ को छोड़कर हर operator तथा special symbol वर्जित है, सो «emp-Addr» और «emp.Sal» दोनों अवैध हैं।
Point 11 says plainly that when one identifier holds several words, separating them with a symbol such as _ is recommended, and its example marks 'perm_Emp_Addr' as recommended and 'permEmpAddr' as not recommended. A - and a . are not even permitted symbols — by point 2 every operator and special symbol apart from _ and $ is forbidden, so both 'emp-Addr' and 'emp.Sal' are invalid.
प्रश्न 10उत्तर + हल
Java identifier में निम्नलिखित में से कौन-सा चिह्न अनुमत है?
Which of the following symbols is allowed in a Java identifier?
  1. A$
  2. B#
  3. C@
  4. D*

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

हल / Solution
theory की मद 1 में identifier के लिए अनुमत वर्णों की सूची है — a से z, A से Z, 0 से 9, _ और $। मद 2 कहती है कि इन दो चिह्नों को छोड़कर बाक़ी सारे operator और special symbol वर्जित हैं, सो #, @ और * तीनों अवैध हैं। पाठ के वैध उदाहरण «float $esal=50000.0f;» और «float emp$Sal=50000.0f;» इसी बात को दिखाते हैं।
Theory point 1 lists the characters allowed in an identifier — a to z, A to Z, 0 to 9, _ and $. Point 2 says that apart from these two symbols every other operator and special symbol is forbidden, so #, @ and * are all invalid. The text's valid examples «float $esal=50000.0f;» and «float emp$Sal=50000.0f;» demonstrate the same point.
आगे के 10 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
App खोलिए
प्रश्न 12उत्तर app में
दिए गए प्रोग्राम का आउटपुट क्या होगा?
class Test{
   public static void main(String[] args) {
      String System="Variable";
      System.out.println(System);
   }
}
Find the output of the given program?
class Test{
   public static void main(String[] args) {
      String System="Variable";
      System.out.println(System);
   }
}
  1. AVariable
  2. Bकंपाइल समय की त्रुटि (Compile-time error)Compile-time error
  3. Cअपवाद (Exception)Exception
  4. Dइनमें से कोई नहींNone of these
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 13उत्तर app में
दिए गए प्रोग्राम का आउटपुट क्या होगा?
class Test{
   public static void main(String[] args) {
      int out=9;
      System.out.print(out+" ");
      println();
   }
   public static void println(){
      System.out.println("Hi");
   }
}
Find the output of the given program?
class Test{
   public static void main(String[] args) {
      int out=9;
      System.out.print(out+" ");
      println();
   }
   public static void println(){
      System.out.println("Hi");
   }
}
  1. A9
  2. B9 Hi
  3. Cकंपाइल समय की त्रुटि (Compile-time error)Compile-time error
  4. Dअपवाद (Exception)Exception
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 14उत्तर app में
नीचे दिए गए प्रोग्राम का आउटपुट क्या है?
public class Test {
   public static void main(String[] args) {
      int abcdefghijklmnopqrstuvwxyz012345 = 6;
      System.out.println(abcdefghijklmnopqrstuvwxyz012345);
   }
}
What is the output of the below program?
public class Test {
   public static void main(String[] args) {
      int abcdefghijklmnopqrstuvwxyz012345 = 6;
      System.out.println(abcdefghijklmnopqrstuvwxyz012345);
   }
}
  1. A0
  2. B6
  3. Cकंपाइल समय की त्रुटि (Compile-time error)Compile-time error
  4. Dअपवाद (Exception)Exception
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 15उत्तर app में
नीचे दिए गए प्रोग्राम का आउटपुट क्या होगा?
public class Test {
   public static void main(String[] args) {
      int a = 9;
      int a = 10;
      System.out.println(a);
   }
}
Find the output of the below program?
public class Test {
   public static void main(String[] args) {
      int a = 9;
      int a = 10;
      System.out.println(a);
   }
}
  1. A9
  2. B10
  3. C19
  4. Dकंपाइल समय की त्रुटि (Compile-time error)Compile-time error
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 17उत्तर app में
दिए गए प्रोग्राम का आउटपुट क्या होगा?
class Test{
   public static void main(String[] args) {
      String String = "String";
      System.out.println(String);
   }
}
Find the output of the given program?
class Test{
   public static void main(String[] args) {
      String String = "String";
      System.out.println(String);
   }
}
  1. AString
  2. Bकंपाइल समय की त्रुटि (Compile-time error)Compile-time error
  3. Cअपवाद (Exception)Exception
  4. Dइनमें से कोई नहींNone of these
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 20उत्तर app में
Java identifier किस चीज़ से शुरू नहीं होने चाहिए?
Java identifiers should not start with?
  1. Aबड़ा अक्षर (UpperCase character)UpperCase Character
  2. Bछोटा अक्षर (LowerCase character)LowerCase Character
  3. Cअंक (Digit)Digit
  4. Dरेखांकन चिह्न (Underscore)Underscore
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
Identifiers of Java के सभी 20 प्रश्न — उत्तर, हल और अभ्यास

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

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

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

Java के दूसरे topics

सभी topics