Caros,
não entendi as linhas abaixo porque essas saida :
b1.print(new Derived());
c1.print(new Derived());
class SuperBase {
void print(SuperBase a){
System.out.println("Super");
}
}
public class Base extends SuperBase {
void print(Base b){
System.out.println("Base");
}
}
package xyz;
public class Derived extends Base {
static void print(Derived d){
System.out.println("Derived");
}
public static void main (String[] args){
SuperBase a1= new SuperBase();
SuperBase b1= new Base();
Base c1= new Derived();
a1.print(new Base());
b1.print(new Derived());
c1.print(new Derived());
}
}
outra duvida no exemplo abaixo a resposta deu truetrue
vendo a resposta do exemplo na internet deu none of these
public static void main(String[] args) {
// TODO Auto-generated method stub
Collection<String> arr= new ArrayList<String>();
ArrayList <Integer> arr1= new ArrayList<Integer>();
arr.add("ABC");
arr.add("XYZ") ;
arr1.add(1);
arr1.add(2);
System.out.println(arr instanceof Collection);
System.out.println(arr.getClass()== arr1.getClass());
what is result of compiling and running the following code?
a) Compile erroe line 6 and 7
b)Compile erroe line 9 and 8
c)Prints truetrue
d)Prints truefalse
e)Prints falsefalse
f)Prints falsetrue
g)none of these
-----------------------------------------------------------
}