Java Programming
primer-original-v2mediumJava Programming03 Class And Objects, Date Apiprimer-original-v2

Given the class Book in packages p1 and class Main in package p2. In main to create an object of Book, which of the following are valid.

Answer options

A
p1.Book bookObj=new p1.Book();
B
import p1.Book; Book bookObj=new Book();
C
import p1.*; Book bookObj=new Book();

Correct answer: p1.Book bookObj=new p1.Book();

Explanation

Quick AnswerThe correct answer is p1.Book bookObj=new p1.Book(); because it directly addresses the core logic of Java Programming.

This question has been retained as-is due to its unique context.

Related Java Programming questions

Practice more Java Programming questions

PrimerPrep has independently reviewed practice questions and coding exercises — all free.