Why are generics used?



Why are generics used?..

Answer / Basudeo Kumar

Generics in Java allow creating reusable, type-safe classes and methods. They provide a way to create flexible code that can work with different data types without having to write separate versions for each.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

In which language JVM (Java Virtual Machine) is implemented

5 Answers  


Name the package that always imported by default?

4 Answers  


What is meant by final class?

1 Answers  


What is aggregation?

1 Answers   Cap Gemini,


What is a boolean structure?

1 Answers  


How is string stored in java?

1 Answers  


Which java ide is used the most?

1 Answers  


What is hard code & soft code?

7 Answers   Cognizant, Wipro,


Is singleton class thread safe?

1 Answers  


What do you mean by compiler?

1 Answers  


Is there any way to find whether software installed in the system is registered by just providing the .exe file? I have tried the following code but its just displaying the directory structure in the registry. Here the code : package com.msi.intaller; import java.util.Iterator; import ca.beq.util.win32.registry.RegistryKey; import ca.beq.util.win32.registry.RootKey; public class RegistryFinder { public static void main(String... args) throws Exception { RegistryKey.initialize(RegistryFinder.class.getResource("jRe gistryKey.dll").getFile()); RegistryKey key = new RegistryKey(RootKey.HKLM, "Software\\ODBC"); for (Iterator<RegistryKey> subkeys = key.subkeys(); subkeys.hasNext();) { RegistryKey subkey = subkeys.next(); System.out.println(subkey.getName()); // You need to check here if there's anything which matches "Mozilla FireFox". } } }

1 Answers   Google,


In Java, what are this() and super(), and where are you required to use them?

2 Answers  


Categories