AdBlocker Detected!

Hello! To continue reading aasansolution.in, please disable your AdBlocker or Brave Shield.

Allowing ads helps us keep our customized Tally TDLs and tools completely free for everyone.

I have whitelisted it - Refresh Page
AS

Question. Explain the purpose of using interfaces(सारांश) in java. जावा में इंटरफेस(सारांश) का उपयोग करने के उद्देश्य की व्याख्या करें।


1) To achieve security - hide certain details and only show the important details by using De-Coupling of an object (interface). So interface deals between client & Developers.

सुरक्षा प्राप्त करने के लिए - Interface का उपयोग केवल सारांश लिखने के लिए किया जाता है इसमें डिटेल को छुपाकर केवल आवश्‍यक चीजों का संक्षेप में उल्‍लेख किया जाता है। यह एक ब्‍लूप्रिंट की भांति होता है जैसे किसी परीक्षा स्‍लेबस। इसलिए इंटरफेस क्लाइंट और डेवलपर्स के बीच डील करता है क्‍योंकि क्‍लांइट को कोड की आवश्‍यकता नहीं होती है उसे तो केवल इनपुट एवं आउटपुट की आवश्‍यकता होती है।

2) 100 % Abstraction (100% सारांशन) - Interface body provides 100% abstraction, so that the sub-class should not miss any implementation of abstract method. This isn't possible if we use abstract classes.

इन्‍टरफेस की बॉडी 100% सारांश उपलब्‍ध कराता है। इसी कारण बनायी गयी सब-क्‍लासेज में इन्‍टरफेस के भीतर के सभी मेथड को भी इम्‍प्‍लीमेंट करना होता है किसी भी मेथड को मिस नहीं किया जाता है। जबकि यह एब्‍ट्रेक्‍ट क्‍लास के माध्‍यम से संभव नहीं है।

 

3) Java does not support "multiple inheritance" (a class can only inherit from one super class). However, it can be achieved with interfaces, because the class can implement multiple interfaces.

जावा मल्‍टीपल इन्‍हेरीटेंस को सपोर्ट नहीं करता है अर्थात जावा में एक क्‍लास की एक से अधिक पेंरेट क्‍लास नहीं हो सकती है। किन्‍तु  इन्‍टरफेस में, एक क्‍लास एक से अधिक इन्‍टरफेस को भी इम्‍पलीमेंट किया जा सकता है।

 

4) Use of interface also is in unit testing. Code which are written using interface are loosely coupled and easier to test because you can easily supply a mock or stub implementation instead of real one.

इन्‍टरफेस का उपयोग यूनिट (सॉफ्टवेयर के अंग/भाग) की टेस्टिंग के लिए भी किया जाता है। चूंकि इन्‍टफेस में इम्‍प्‍लीमेंट की जाने वाली समस्‍त बातों का सारांश होता है। अत: सारांश के रूप में लिखे गये सॉफ्टवेयर को क्‍लाइंट द्वारा चैक कर पाना ज्‍यादा आसान हो जाता है।


Fast Index