Вы находитесь на странице: 1из 2

Topic: Abstract Classes, Interfaces

Given:
1. abstract class MyClass {
2.

void init() { }

3.

abstract int calculate();

4. }
5. class MyImpl extends MyClass {
6.

int calculate() {

7.

System.out.println("Invoking calculate...");

8.

return 1;

9.

10.}
11.public class TestMyImpl {
12.

public static void main(String[] args) {

13.

MyImpl mi = new MyImpl();

14.

mi.init();

15.

mi.calculate();

16.

17.}
What is the expected behaviour?
Prints "Invoking calculate...".
Runtime error occurs.
Compilation error at line 2.
Compilation error at line 14.
Topic: Access Modifiers
Which one of the following modifiers can be applied to a method?
transient
native

volatile
friend
Topic: Access Modifiers
Given a method in a class, what access modifier do you use to restrict
access to that method to only the other members of the same class?
static
private
protected
volatile
Topic: Access Modifiers
Which of the following modifiers can be applied to a constructor?
protected
static
synchronized
transient
Topic: Access Modifiers
Which of the following member level (i.e. nonlocal) variable declarations
will not compile?
transient int b = 3;
public static final int c;
volatile int d;
private synchronized int e;

Вам также может понравиться