- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHackerrankJava0051.java
More file actions
Latest commit
43 lines (32 loc) · 1.33 KB
/
Copy pathHackerrankJava0051.java
File metadata and controls
43 lines (32 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
importjava.util.Scanner;
publicclassHackerrankJava0051 {
publicstaticvoidmain(String[] args) {
// Java Abstract Class
// https://www.hackerrank.com/challenges/java-abstract-class/problem?isFullScreen=true
// Book new_novel=new Book(); This line prHMain.java:25: error: Book is abstract; cannot be instantiated
Scannersc = newScanner(System.in);
Stringtitle = sc.nextLine();
MyBooknew_novel = newMyBook();
new_novel.setTitle(title);
System.out.println("The title is: " + new_novel.getTitle());
sc.close();
}
}
abstractclassBook {
Stringtitle;
abstractvoidsetTitle(Strings);
StringgetTitle() {
returntitle;
}
}
// -------------------------------------------------------------------------------------------------
// --- You need to add this lines for solution hackerrank provides all other lines for challange ---
// -------------------------------------------------------------------------------------------------
classMyBookextendsBook {
voidsetTitle(Stringtitle) {
super.title = title;
}
}
// -------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------