List l = new Arraylist(); if you use this line in your code what will we get?
Compilation error.
Runtime error
Compiles Fine
Depends on the code where you use
Which statements are true?
Inheritance defines a has-a relationship between a superclass and its subclasses
Every Java object has a public method named equals
A class can extend any number of other classes
A non-final class can be extended by any number of classes
public void addAnimal(List super Dog> animals) { animals.add(new Dog()); } it's NOT legal to add when we use Wildcard character >.(True/ False)
True
False
Runtime error.
1.Set s = new HashSet(); 2.s.add("JAVA"); 3.s.add(new Integer(5)); Line 3 will give ClassCast Exception because Two different types of object are getting added.
1.Set s = new TreeSet(); 2.s.add("JAVA"); 3.s.add(new Integer(5)); Line 3 will give ClassCast Exception because Two different types of object are getting added.