محاضرة أستاذ خالد هذا الاسبوع
مفهوم
super
final
override
upcasting
downcasting
مفهوم
super
final
override
upcasting
downcasting
class Main {
public static void main(String[] args) {
Child c = new Child(5);
}
class Parent {
Parent(int x) {
System.out.print("x");
}
Parent(String A) {
System.out.print(A);
}
}
class Child extends Parent {
Child(String name) {
super("10"); // استدعاء constructor of Parent with String parameter
System.out.print(name);
}
}
}شن الرن؟
تتبع اسئلة امتحانات
:
ما ناتج البرنامج على الشاشة الرن؟؟
java
class Main {
public static void main(String[] args) {
Child c = new Child("5");
}
class Parent {
Parent(int x) {
System.out.print(p int);
}
Parent(String A) {
System.out.print(A);
}
}
class Child extends Parent {
Child(int num) {
super("10");
System.out.print("int");
}
}
ما ناتج البرنامج على الشاشة الرن؟؟
👍1
package run;
class A
{
A()
{
this("khalid");
System.out.println("A");
}
public A(String c)
{
System.out.println(c);
}
}
class B extends A
{
B()
{
this("mohammed");
System.out.println("B");
}
public B(String c)
{
System.out.println(c);
}
}
class C extends B
{
C()
{
System.out.println("Erfadi");
}
public C(String c)
{
this();
System.out.println(c);
}
}
public class Run {
public static void main(String[] args)
{
C c=new C("khalid");
}
}
تتبع استاذ خالد