Question: 1. What is the proper way to utilize the enum declared below? Select the one correct answer. public enum Suit { HEARTS, CLUBS, SPADES, DIAMONDS

1. What is the proper way to utilize the enum declared below? Select the one correct answer. public enum Suit { HEARTS, CLUBS, SPADES, DIAMONDS }

A. Suit suit = Suit.HEARTS;

B. int suit = Suit.CLUBS;

C. String suit = Suit.SPADES;

D. None of the above

2.Given the following class, which of these are valid ways of referring to the class from outside of the package net.basemaster? Select the two correct answers. package net.basemaster; public class Base { // class stuff here }

A. By simply referring to the class as Base

B. By simply referring to the class as basemaster.Base

C. By simply referring to the class as net.basemaster.Base

D. By importing with net.basemaster.* and referring to the class as Base

E. By importing with net.* and referring to the class as basemaster.Base

3.Which is the correct order that the class, package, and import statements should appear? Select the one correct answer.

  • A. class, import, package
  • B. package, class, import
  • C. import, class, package
  • D. package, import, class
  • E. import, package, class

4.Given the following code, what is the result when run? Select the one correct answer. public class Program { public static void main(String args [] ) {!@ short x = 2; x++;## short y = 3 + x++; System.out.print(y); } }

  • A. 7
  • B. 6
  • C. 5
  • D. An Exception occurs
  • E. Compilation fails

5.Given the following definition of a class, which fields are accessible from outside the package com.corporation.project? Select the two correct answers. package com.corporation.project; public class MyClass { int i; public int j; protected int k; private int el; }

A. Field i is accessible in all classes in other packages

B. Field j is accessible in all classes in other packages

C. Field k is accessible in all classes in other packages

D. Field k is accessible in subclasses only in other packages

E. Field el is accessible in all classes in other packages

F. Field el is accessible in subclasses only in other packages

6.if a class is named CoolClass, which method signatures are legitimate constructors for the class? Select the one correct answer.

  • A. public void CoolClass()
  • B. private void CoolClass(int x)
  • C. public CoolClass(double z)
  • D. public int CoolClass(int z)

7. In order to follow the principles of encapsulation, class attributes should have which access modifier? Select the one correct answer.

  • A. default
  • B. private
  • C. protected
  • D. public

8. Which of the following is the suggested way to access the value attribute of the Storage class? Assume there is a Storage object that has been created with the name obj. Select the one correct answer.

  • A. Storage.value
  • B. Storage.obj.value
  • C. Storage.getValue()
  • D. obj.getValue()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!