Test Your Understanding - Packages (Copy) - Attempt Review
Test Your Understanding - Packages (Copy) - Attempt Review
Dashboard / App Dev / Stage - 1 / Java Programming / Classes and Objects, Packages
Quiz review
Started on Wednesday, 13 September 2023, 12:02 AM
State Finished
Completed on Wednesday, 13 September 2023, 12:18 AM
Time taken 16 mins 40 secs
Marks 5.00/5.00
Grade 100.00 out of 100.00
Feedback Congratulations!!! You have passed by securing more than 80%
37547
37547
37547
https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=69972&cmid=1220 1/6
9/13/23, 12:19 AM Test your understanding - Packages (copy): Attempt review
Question 1
Correct
Choose the correct option so that the code runs without any compilation errors
a. package test;
b. import java.util.Scanner;
}
37547
c. package test;
import java.util.Scanner;
d. import java.util.Scanner;
}
// Some code
37547
package test;
import java.util.Scanner;
public class Main {
}
// Some code
37547
https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=69972&cmid=1220 2/6
9/13/23, 12:19 AM Test your understanding - Packages (copy): Attempt review
Question 2
Correct
37547
a. import static java.lang.Math.PI;
b. import java.lang.Math.PI;
37547
37547
https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=69972&cmid=1220 3/6
9/13/23, 12:19 AM Test your understanding - Packages (copy): Attempt review
Question 3
Correct
4. }
1. package util;
2. public class Library {
3. public static void main(String[] args) {
4. // insert code here
37547
5. }
6. }
What is required at line 4 in class Library to use the countBook method of Book class?
Select one:
a. util.Library.countBook();
b. countBook();
c. model.Book.countBook();
d. Book.countBook();
37547
countBook() cannot be invoked since the method is declared private.
The correct answer is: Library class cannot use the countBook method in Book class.
37547
https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=69972&cmid=1220 4/6
9/13/23, 12:19 AM Test your understanding - Packages (copy): Attempt review
Question 4
Correct
Assume class Calculator in package p1 and CalculatorService class in package p2 as shown below.
package p1;
public class Calculator {
__________ static void calculate(){
37547
public void display(){
Calculator.calculate();
}
}
What can be the valid access specifier for the calculate method in Calculator class so that it can be accessed from CalculatorService
class?
Select one:
a. Any access specifier except private
b. default
37547
c. private
d. protected
e. public
If a method defined within a class in one package has to be invoked from outside, then that method has to be declared public.
37547
https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=69972&cmid=1220 5/6
9/13/23, 12:19 AM Test your understanding - Packages (copy): Attempt review
Question 5
Correct
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.
Select one:
a. p1.Book bookObj=new p1.Book();
Since the Book class is present within p1 package, it has to be accessed as "p1.Book", everytime, from package p2.
The correct answer is: p1.Book bookObj=new p1.Book();
37547
◄ Packages
Jump to...
37547
37547
https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=69972&cmid=1220 6/6