0

Java Declarations and Access Control Quiz

Description: Java Declarations and Access Control Quiz
Number of Questions: 8
Created by:
Tags: java
Attempted 0/8 Correct 0 Score 0
  1. public

  2. protected

  3. private

  4. transient


Correct Option: B
Explanation:

protected makes a member accessible only to classes in the same package or subclass of the class

  1. public

  2. abstract

  3. protected

  4. synchronized

  5. default access


Correct Option: E
Explanation:

default access is the "package oriented" access modifier.

  1. int[ ] scores = {3, 5, 7};

  2. int [ ][ ] scores = {2,7,6}, {9,3,45};

  3. String cats[ ] = {"Fluffy", "Spot", "Zeus"};

  4. boolean results[ ] = new boolean [] {true, false, true};


Correct Option: B
  1. int[ ] ia = new int[15];

  2. float fa = new float[20];

  3. char[ ] ca = "Some String";

  4. int ia[ ] [ ] = { 4, 5, 6 }, { 1,2,3 };


Correct Option: A
  1. protected int a;

  2. transient int b = 3;

  3. private synchronized int e;

  4. volatile int d;


Correct Option: C
  1. final

  2. static

  3. private

  4. protected


Correct Option: C
Explanation:

The private access modifier limits access to members of the same class.

Which is a valid declaration within an interface?

  1. public static short stop = 23;

  2. protected short stop = 23;

  3. transient short stop = 23;

  4. final void madness(short stop);


Correct Option: A
- Hide questions