We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fbdda86 commit d17d536Copy full SHA for d17d536
1 file changed
OOPs/constructor/Book_1.java
@@ -0,0 +1,25 @@
1
+package constructor;
2
+
3
+import java.sql.SQLOutput;
4
5
+class Book_2 {
6
+ double price;
7
+ String title;
8
9
+ Book_2(){
10
+ price = 99.9;
11
+ title = "Java Programming";
12
+ }
13
+ Book_2(double price, String title) {
14
+ this.price = price;
15
+ this.title = title;
16
17
18
+ static void main() {
19
+ Book_2 book_1 = new Book_2();
20
+ Book_2 book_2 = new Book_2(120.46, "Data Structures");
21
22
+ System.out.println("Book 1: " + book_1.title + " with price $" + book_1.price);
23
+ System.out.println("Book 2: " + book_2.title + " with price $" + book_2.price);
24
25
+}
0 commit comments