Java OCA OCP Practice Question 2359

Question

A class Course is defined in a package com.mypkg.

Given that the physical location of the corresponding class file is /mypkg1/com/mypkg/Course.

class and execution takes place within the mypkg1 directory, which of the following lines of code, when inserted at // INSERT CODE HERE, will import the Course class into the class MyCourse?

// INSERT CODE HERE 
class MyCourse { 
    Course c; 
} 
  • a import mypkg1.com.mypkg.Course;
  • b import com.mypkg.Course;
  • c import mypkg1.com.mypkg;
  • d import com.mypkg;
  • e import mypkg1.com.mypkg*;
  • f import com.mypkg*;


b

Note

Option a is incorrect.

The base directory, mypkg1, in which package com.

mypkg is defined, must not be included in the import statement.

Options c and e are incorrect.

The class's physical location isn't specified in the import statement.

Options d and f are incorrect.

mypkg is a package.

To import a package and its members, the package name should be followed by.

*, as follows:.

import com.mypkg.*; 



PreviousNext

Related