Question
Difference between List< ? > and List < Object > in Java

Answers

This generics interview question may look related to previous interview questions but completely different. List< ? > is List of unknown type while List< Object > is essentially List of any Type. You can assign List , List to List< ? > but you can not assign List to List< Object >.

List< ?> listOfAnyType;
List< Object > listOfObject = new ArrayList< Object >();
List< String > listOfString = new ArrayList< String >();
List< Integer > listOfInteger = new ArrayList< Integer >();
listOfAnyType = listOfString; //legal
listOfAnyType = listOfInteger; //legal
listOfObjectType = (List< Object>) listOfString; //compiler error - in-convertible types   Your Comment




More Software,Java Questions..
What is the inputsplit in map reduce software?

Can variables be used in Java without initialization?

What is the difference between java bean and enterprise java bean?

What is software configuration management?

How does the java database connectivity (jdbc) work?

What are the advantages of threads in java?

What Is Java Api For Xml-based Rpc (jax-rpc)?

How can you implement fine-grained auditing?

What is IBM’s simple explanation for Big Data’s four critical features?

What is static synchronized method in JDBC API? Give an example?

What does the NULLIF function do?

What happens if a start method is not invoked and the run method is directly invoked?

Should we override finalize method

what is the difference between mysql_fetch_array and mysql_fetch_object?

How will XML affect my document links?

What is object cloning in Java?

Why to use Style Sheets?

What are Filters in MVC?

Can you explain Application layer in OSI model?

How to define new testplan attributes?



Search
Can you Answer!!
  • Q Who was the leader of the wolves in The Jungle Book?
  • Q Which garden is considered to be among the Seven Wonders of the Ancient World?
  • Q The Suez Canal was nationalized in:
  • Q Who was the first lady Prime Minister in the world?
  • Q Which two commands can you use to delete directories?
  • Q What is the difference between Stroke volume and Cardiac output?
  • Q Satavahanas were also known as:
  • Q Where is the Tilde used?
  • Q What is form factor and peak factor?
  • Q Name of the first player who was Six sixes in an Over.
  • Q Ba is the bridge between the it and non-it persons when it comes a software system. Does it mean that decision making responsibility can be rested his hand entirely?