Blog - Java Quiz 1

Java Quiz 1

Java Quiz 1

Java

 

1. What does JDK stand for?

जेडीके का क्या मतलब है?

a) Java Development Kit

b) Java Developer Kit

c) Java Deployment Kit

d) Java Design Kit

Answer: a) Java Development Kit

 

2. Which keyword is used to define a constant in Java?

जावा में स्थिरांक को परिभाषित करने के लिए किस कीवर्ड का उपयोग किया जाता है?

a) var

b) static

c) final

d) constant

Answer: c) final

 

3. In Java, which data type is used to store whole numbers?

जावा में पूर्ण संख्याओं को संग्रहीत करने के लिए किस डेटा प्रकार का उपयोग किया जाता है?

a) float

b) double

c) int

d) char

Answer: c) int

 

4.   What is the correct syntax to declare an array in Java?

जावा में किसी ऐरे को घोषित करने के लिए सही सिंटैक्स क्या है?

a) int[] myArray;

b) array myArray[];

c) int myArray[];

d) myArray[] int;

Answer: a) int[] myArray;

 

5. Which operator is used for string concatenation in Java?

जावा में स्ट्रिंग संयोजन के लिए किस ऑपरेटर का उपयोग किया जाता है?

a) +

b) &

c) ||

d) ,

Answer: a) +

 

6. What is the output of the code snippet: System.out.println(5 + "2");?

कोड स्निपेट का आउटपुट क्या है: System.out.println(5 + "2");?

a) 7

b) 52

c) 2

d) 5

Answer: b) 52

 

7.  In Java, what is the purpose of the "this" keyword?

जावा में, "इस" कीवर्ड का उद्देश्य क्या है?

a) It refers to the current class object.

b) It is used to create new objects.

c) It refers to the parent class.

d) It is used to print messages.

Answer: a) It refers to the current class object.

 

8.  Which keyword is used to create an instance of a class in Java?

जावा में क्लास का इंस्टेंस बनाने के लिए किस कीवर्ड का उपयोग किया जाता है?

a) object

b) new

c) create

d) instance

Answer: b) new

 

9. What is the default value of a boolean variable in Java?

जावा में बूलियन वेरिएबल का डिफ़ॉल्ट मान क्या है?

a) true

b) false

c) 0

d) 1

Answer: b) false

 

10. What is the purpose of the "break" statement in Java?

जावा में "ब्रेक" स्टेटमेंट का उद्देश्य क्या है?

a) To exit a loop or switch statement.

b) To continue to the next iteration of a loop.

c) To declare a variable.

d) To print a message.

Answer: a) To exit a loop or switch statement.

 

11. Which Java keyword is used to define a subclass?

उपवर्ग को परिभाषित करने के लिए किस जावा कीवर्ड का उपयोग किया जाता है?

a) super

b) extends

c) subclass

d) parent

Answer: b) extends

 

12. What is the return type of the "main" method in Java?

जावा में "मुख्य" विधि का रिटर्न प्रकार क्या है?

a) void

b) int

c) String

d) boolean

Answer: b) int

 

13. Which Java package contains the Scanner class for input?

किस जावा पैकेज में इनपुट के लिए स्कैनर क्लास शामिल है?

a) java.util

b) java.io

c) java.lang

d) java.input

Answer: a) java.util

 

 

14. What is the purpose of the "try-catch" block in Java?

जावा में "ट्राई-कैच" ब्लॉक का उद्देश्य क्या है?

a) To declare variables.

b) To handle exceptions.

c) To define loops.

d) To create objects.

Answer: b) To handle exceptions.

 

15. Which data structure follows the "Last In, First Out" (LIFO) principle?

कौन सी डेटा संरचना "लास्ट इन, फर्स्ट आउट" (LIFO) सिद्धांत का पालन करती है?

a) Queue

b) Stack

c) Linked List

d) Array

Answer: b) Stack

 

16. Which Java interface must be implemented by a class that wants to use the "compareTo" method?

कौन सा जावा इंटरफ़ेस उस वर्ग द्वारा कार्यान्वित किया जाना चाहिए जो "compareTo" पद्धति का उपयोग करना चाहता है?

a) Comparable

b) Serializable

c) Comparator

d) Iterable

Answer: a) Comparable

 

17. What is the maximum value that can be held by a byte data type in Java? 

जावा में बाइट डेटा प्रकार द्वारा रखा जा सकने वाला अधिकतम मान क्या है?

a) 128

b) 255

) 32767

d) 2147483647

Answer: b) 255

 

18. How is method overloading different from method overriding in Java?

  जावा में मेथड ओवरलोडिंग मेथड ओवरराइडिंग से किस प्रकार भिन्न है?

a) Method overloading changes the method name; method overriding doesn't.

b) Method overloading occurs within the same class; method overriding occurs in different classes.

c) Method overloading is static; method overriding is dynamic.

d) Method overloading involves creating a new method with a different signature; method overriding redefines a method in a subclass.

Answer: d) Method overloading involves creating a new method with a different signature; method overriding redefines a method in a subclass.

 

19. Which of the following access modifiers makes a class or method accessible only within the same package?

निम्नलिखित में से कौन सा एक्सेस संशोधक एक वर्ग या विधि को केवल उसी पैकेज के भीतर पहुंच योग्य बनाता है?

 

a) private

b) protected

c) default

d) public

Answer: c) default

 

20. What is the purpose of the "super" keyword in Java?

जावा में "सुपर" कीवर्ड का उद्देश्य क्या है?

a) To call the superclass constructor.

b) To create a new object.

c) To access static members.

d) To print a message.

Answer: a) To call the superclass constructor.

 

21. How do you declare a constant in an interface in Java?

आप जावा में किसी इंटरफ़ेस में स्थिरांक की घोषणा कैसे करते हैं?

a) Using the "constant" keyword.

b) Constants cannot be declared in interfaces.

c) Using the "final" keyword.

d) Using the "static" keyword.

Answer: c) Using the "final" keyword.

 

22. Which type of exception is thrown when an array index is out of bounds?

जब कोई ऐरे इंडेक्स सीमा से बाहर होता है तो किस प्रकार का अपवाद फेंका जाता है?

a) NullPointerException

b) ArrayIndexOutOfBoundsException

c) IndexOutOfBoundsException

d) ArrayBoundsException

Answer: b) ArrayIndexOutOfBoundsException

 

23. What is the purpose of the "finally" block in a try-catch-finally structure?

ट्राई-कैच-आखिरकार संरचना में "अंततः" ब्लॉक का उद्देश्य क्या है?

a) To handle exceptions.

b) To define loops.

c) To ensure a block of code always executes.

d) To create objects.

Answer: c) To ensure a block of code always executes.

 

24. In Java, what is the purpose of the "static" keyword when applied to a method?

जावा में, किसी विधि पर लागू होने पर "स्थैतिक" कीवर्ड का उद्देश्य क्या है?

a) It indicates that the method can be overridden

  b) It allows the method to access non-static members.

c) It indicates that the method belongs to the class, not to an instance of the class.

d) It makes the method private.

Answer: c) It indicates that the method belongs to the class, not to an instance of the class. 

 

 

25.Which of the following is not a valid identifier in Java?

निम्नलिखित में से कौन सा जावा में वैध पहचानकर्ता नहीं है?

a) my_variable

b) 123_variable

c) _myVariable

d) $myVariable

Answer: b) 123_variable


83 8 months ago