40. What is the output of the following code? interface calculate { void cal (int item); } class display implements calculate { int x; public void cal (int item) { x = item * item; } } class interfaces { public static void main(String args[]) { display arr = new display; arr.x = 0; arr.cal(2); System.out.print(arr.x); } } a) 0 b) 2 c) 4 d) compile error e) None of the mentioned
Added by Derrick B.
Close
Step 1
We have an interface called "calculate" with a method declaration "void cal(int item)", a class "display" that implements this interface, and a class "interfaces" with the main method. Show more…
Show all steps
Your feedback will help us improve your experience
Reynald Oliveria and 74 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
What will be output from the following code segment, assuming it is in the same class as the do something method? int [] arr $=\{1,2,3,4\}$ doSomething (arr) ; System.out.print $(\operatorname{arr}[1]+" ")$ System.out.print(arr[3]); public void doSomething(int [] list) { int [] b $=1$ ist for (int $i=0 ; \text { i }<\text { b. length; } i++)$ $b[i]=i$ } (A) 00 (B) 24 (C) 13 (D) 02 (E) 0 3
What is the output of the following? class GFG { public static void main (String[] args) { int[] arr = new int[2]; arr[0] = 10; arr[1] = 20; for (int i = 0; i < arr.length; i++) System.out.println(arr[i]); } }
Madhur L.
With the following declaration: intƒ[ƒ,ƒ]ƒpointsƒ=ƒ ƒƒƒƒƒƒƒ{{300,ƒ100,ƒ200,ƒ400,ƒ600}, ƒƒƒƒƒƒƒƒ{550,ƒ700,ƒ900,ƒ200,ƒ100}}; The statement Console.Write(points [1, 2] + points [0, 3]); will a. display 900400 b. display 1300 c. display “points[1, 2] + points[0, 3]” d. result in an error e. none of the above
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD