We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 63e6104 commit bde055bCopy full SHA for bde055b
1 file changed
1st_November_exam_SET-2/JAVA_SET_2_Q5.java
@@ -0,0 +1,26 @@
1
+import java.util.Scanner;
2
+interface Number {
3
+ int findCube(int i); // Returns the cube of a number
4
+}
5
+
6
7
+//Create a class A which implements the interface Number.
8
+class A implements Number
9
+{
10
+public int findCube
11
+(int num)
12
13
+return num*num*num;
14
15
16
17
18
+public class Question5{
19
+ public static void main (String[] args){
20
+ A a = new A(); //Create an object of class A
21
+ // Read a number from the keyboard
22
+ Scanner sc = new Scanner(System.in);
23
+ int n = sc.nextInt();
24
+ System.out.print(a.findCube(n));
25
+ }
26
0 commit comments