Given:class Bird {public void fly () { System.out.print("Can fly"); }}class Penguin extends Bird {public void fly () { System.out.print("Cannot fly"); }}and the code fragment:class Birdie {public static void main (String [ ] args) {fly( ( ) -> new Bird ( ));fly (Penguin : : new);}/* line n1 */}line n1, enables the Birdie class to compile?Which code fragment, when inserted at
Given:1. abstract class Shape {2. Shape ( ) { System.out.println ("Shape"); }3. protected void area ( ) { System.out.println ("Shape"); }4. }5.6. class Square extends Shape {7. int side;8. Square int side {9. /* insert code here */10. this.side = side;11. }12. public void area ( ) { System.out.println ("Square"); }13. }14. class Rectangle extends Square {15. int len, br;16. Rectangle (int x, int y) {17. /* insert code here */18. len = x, br = y;19. }20. void area ( ) { System.out.println ("Rectangle"); }21. }Which two modifications enable the code to compile?abstract
Which two reasons should you use interfaces instead of abstract classes? (Choose two.)
Given:public class Foo<K, V> {private K key;private V value;public Foo (K key, V value) (this.key = key; this value = value;) public static <T> Foo<T, T> twice (T value) (return new Foo<T, T> (value, value); ) public K getKey () (return key;) public V getValue () (return value;)}Which option fails?Foo<String, Integer> mark = new Foo<String, Integer> ("Steve", 100););A.B. Foo<String, String> pair = Foo.<String>twice ("Hello World!");Foo<?, ?> percentage = new Foo <> (97, 32););C.D. Foo<String, String> grade = new Foo <> ("John", "A");
Given:public class Counter {public static void main (String[ ] args) {int a = 10;int b = -1;assert (b >=1) : "Invalid Denominator";int Ñ = a / b;System.out.println (c);}}What is the result of running the code with the ""ea option?
Given the definition of the Vehicle class:Class Vehhicle {int distance; //line n1Vehicle (int x) {this distance = x;}public void increSpeed(int time) { //line n2int timeTravel = time; //line n3class Car {int value = 0;public void speed () {value = distance /timeTravel;System.out.println ("Velocity with new speed"+value+"kmph");}}new Car().speed();}}and this code fragment:Vehicle v = new Vehicle (100);v.increSpeed(60);What is the result?Velocity with new speed -