Answer the question
In order to leave comments, you need to log in
Is this code OOP?
public abstract class C {
public void c(){
System.out.println("Меня зовут");
}
}
public class A extends C implements D{
C c = new C() {};
public void a(){
System.out.print("Иванов ");
System.out.println("Иван");
}
@Override
public void d() {
System.out.println("Я живу в большом городе");
}
}
interface D {
public void d();
}
public class B extends A{
A a = new A();
private int age;
public void setage(int a){
this.age = a;
}
public int getage(){
return age;
}
public void b(){
B b = new B();
a.c();
a.a();
a.d();
b.setage(20);
System.out.println("Мне " + b.getage() + " лет");
}
}
public class E {
public static void main(String[] args) {
B b = new B();
b.b();
}
}
Answer the question
In order to leave comments, you need to log in
Good afternoon.
Is the code OOP - yes, it is. But as a colleague noted, it is worth working on it. Read about java naming convention.
There is also a good course at https://refactoring.guru/refactoring
Classes should have a clear name
class B extends A
Do not forget about camelCase
b.setage(20);
The public access modifier in the interface is superfluous
interface D {
public void d();
}
C c = new C();
I can say for sure that the code is garbage, with such a naming.
By what principle is the code divided here?
Is this code OOP?yes, but this is not your merit, just an object-oriented language and makes the principles of OOP use
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question