Looking for Об'єктно-орієнтоване програмування test answers and solutions? Browse our comprehensive collection of verified answers for Об'єктно-орієнтоване програмування at virt.ldubgd.edu.ua.
Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!
Зовнішній клас має доступ до членів вкладеного класу за умови:
Чому метод showy () не буде компільований
class Outer {
int outer_x = 100;
void test() {
Inner inner = new Inner();
inner.display();
}
class Inner {
int y = 10; //локальна змінна класу Inner
void display() {
System.out.println(outer_x);
}
}
void showy () {
System.out.println(y);
}
}
Яким чином з класу нащадка можливо організувати доступ до закритих змінних ( ) батьківського класу:
Яке ключове слово відповідає за наслідування
Не статичний вкладений клас – це:
Яка стрічка з наведено фрагменту програмного коду не компілюється у
class Box {
private double width;
private double height;
private double depth;
Box (Box ob){
width = ob.width;
height = ob.height;
depth = ob.depth;
}
Box (double w, double h, double d){
width = w;
height = h;
depth = d;
}
}
public class BoxWeight extends Box {
double weight;
BoxWeight(BoxWeight ob) {
super(ob);
weight = ob.weight;
}
BoxWeight(double w, double h, double d, double m) {
super(w, h, d);
weight = m;
}
}
public class BoxWeightDemo {
public static void main(String[] args) {
BoxWeight mybox1 = new BoxWeight(10, 20, 15, 34.3);
BoxWeight mybox2 = new BoxWeight();
BoxWeight mycube = new BoxWeight(3, 2);
BoxWeight myclone = new BoxWeight(mybox1);
}
}Яку роль відіграє стрічка super(w, h, d); в наведеному фрагменті коду:
public class BoxWeight extends Box {
double weight;
BoxWeight(double w, double h, double d, double m) {
super(w, h, d);
weight = m;
}
}
Основна ідея наслідування полягає у:
Чи буде доступний метод
class Box {
double width;
double height;
double depth;
void trable(){
double c = width+ height
}
}
class BoxWeight extends Box {
}
Чи являється клас
class Outer {
int outer_x = 100;
void test() {
Inner inner = new Inner();
inner.display();
}
}
class Inner {
int y = 10; //локальна змінна класу Inner
void display() {
System.out.println(outer_x);
}
}