What will be the output of following java program ??
This Program complies fine, but throws a run time exception saying ArrayStoreException.
This particular exception comes when we try to store the wrong type of object into an array of objects.
Here the asList() method do not convert Array into List , it just virtually shows a List represents of an Array.
Arrays have a characteristics that they are
- fixed in size
- can store only homogeneous(similar type) values.
That's why we get exception at line l.add("word");
Never get confused in exam, practice hard is the mantra to get success in OCJP.
No comments:
Post a Comment