Menu
Question Index
...

Write code for creating the Book object and assigning it to the object reference java. Using the dot operator on the reference java, set the name to "Java The Complete Reference", author to "Herbert Schildt", edition to 7, numberOfPages to 1116 and the price to 527.5



class BookTester
{
    public static void main(String s[])
    {
        Book java = createJavaBook();
        System.out.println("Book Name = " + java.name);
        System.out.println("Author = " + java.author);
        System.out.println("Edition = " + java.edition);
        System.out.println("Pages = " + java.numberOfPages);
        System.out.println("Price = Rs. " + java.price);

    }


    public static Book createJavaBook()
    {
    }

}
class Book
{
    String name;
    String author;
    int edition;
    int numberOfPages;
    double price;
}

Doubts

Problems

Topic: Class References And Objects In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App