0% found this document useful (0 votes)
38 views1 page

q1 Solution

This document contains code examples of class definitions with access modifiers. It asks to identify incorrect lines in the given class definitions. The document contains 5 code examples of classes extending or accessing fields of another class, with some lines of code marked as incorrect access of fields due to access modifiers.

Uploaded by

İsmail Cambaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views1 page

q1 Solution

This document contains code examples of class definitions with access modifiers. It asks to identify incorrect lines in the given class definitions. The document contains 5 code examples of classes extending or accessing fields of another class, with some lines of code marked as incorrect access of fields due to access modifiers.

Uploaded by

İsmail Cambaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Q.1) Aşağıda verilen sınıf tanımlamalarında hatalı satırları işaretleyiniz.

package earth;

public class A {
private int m_private;
protected int m_protected;
int m_default;
public int m_public;
}

package earth;

public class B extends A {


public void f() {
m_private = 1; x
m_protected = 2;
m_default = 3;
m_public = 4;
}
}

package moon;

public class C extends earth.A {


public void f() {
m_private = 1; x
m_protected = 2;
m_default = 3; x
m_public = 4;
}
}

package earth;

public class D {
public void f(A a){
a.m_private = 1; x
a.m_protected = 2;
a.m_default = 3;
a.m_public = 4;
}
}

package moon;

public class E {
public void f(earth.A a){
a.m_private = 1; X
a.m_protected = 2; X
a.m_default = 3; X
a.m_public = 4;
}
}

You might also like