Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
1fd5a71
Merge pull request #198 from ResilientSpring/Laptop
ResilientSpring Oct 1, 2023
79aa9f0
Merge pull request #199 from ResilientSpring/Laptop
ResilientSpring Oct 1, 2023
49e3d93
Merge pull request #200 from ResilientSpring/Laptop
ResilientSpring Oct 1, 2023
79b3439
Merge pull request #201 from ResilientSpring/master
ResilientSpring Oct 2, 2023
5dc30ec
Merge pull request #202 from ResilientSpring/SP7
ResilientSpring Oct 2, 2023
9216159
Committed on or around 2023/10/02
ResilientSpring Oct 2, 2023
facb3e5
Committed on or around 2023/10/02
ResilientSpring Oct 2, 2023
59c52d6
Committed on or around 2023/10/02
ResilientSpring Oct 2, 2023
072f35a
Committed on or around 2023/10/02
ResilientSpring Oct 2, 2023
9dcc395
Committed on or around 2023/10/02
ResilientSpring Oct 2, 2023
97c2b48
Committed on or around 2023/10/02
ResilientSpring Oct 2, 2023
98c333b
Committed on or around 2023/10/02
ResilientSpring Oct 2, 2023
6cf5833
Committed on or around 2023/10/02
ResilientSpring Oct 2, 2023
6ab7e4c
Committed on or around 2023/10/02
ResilientSpring Oct 2, 2023
8f9ca42
Committed on or around 2023/10/02
ResilientSpring Oct 2, 2023
43dfb3d
Committed on or around 2023/10/02
ResilientSpring Oct 2, 2023
90575cb
Committed on or around 2023/10/03
ResilientSpring Oct 2, 2023
2b76034
Committed on or around 2023/10/03
ResilientSpring Oct 2, 2023
c47d68e
Committed on or around 2023/10/03
ResilientSpring Oct 2, 2023
bc3f05d
Committed on or around 2023/10/03
ResilientSpring Oct 2, 2023
63e96da
Merge pull request #203 from ResilientSpring/SP7
ResilientSpring Oct 2, 2023
9983e26
Committed on or around 2023/10/03
ResilientSpring Oct 3, 2023
d972d30
Committed on or around 2023/10/03
ResilientSpring Oct 3, 2023
3944846
Committed on or around 2023/10/03
ResilientSpring Oct 3, 2023
77dd325
Committed on or around 2023/10/03
ResilientSpring Oct 3, 2023
62ee7e4
Committed on or around 2023/10/03
ResilientSpring Oct 3, 2023
fdb7b1e
Committed on or around 2023/10/03
ResilientSpring Oct 3, 2023
c6118f9
Committed on or around 2023/10/03
ResilientSpring Oct 3, 2023
4b36e2b
Committed on or around 2023/10/03
ResilientSpring Oct 3, 2023
b1f3462
Committed on or around 2023/10/03
ResilientSpring Oct 3, 2023
f1396e2
Committed on or around 2023/10/03
ResilientSpring Oct 3, 2023
5210b57
Committed on or around 2023/10/03
ResilientSpring Oct 3, 2023
85615cd
Committed on or around 2023/10/03
ResilientSpring Oct 3, 2023
935042f
Committed on or around 2023/10/03
ResilientSpring Oct 3, 2023
421badb
Committed on or around 2023/10/03
ResilientSpring Oct 3, 2023
d4331dc
Committed on or around 2023/10/04
ResilientSpring Oct 3, 2023
547a382
Committed on or around 2023/10/04
ResilientSpring Oct 3, 2023
a80ed15
Committed on or around 2023/10/04
ResilientSpring Oct 3, 2023
cf76057
Merge pull request #204 from ResilientSpring/SP7
ResilientSpring Oct 3, 2023
e3e15dc
Committed on or around 2023/10/04
ResilientSpring Oct 4, 2023
30e0870
Committed on or around 2023/10/04
ResilientSpring Oct 4, 2023
14325f9
Committed on or around 2023/10/04
ResilientSpring Oct 4, 2023
1165d4b
Committed on or around 2023/10/04
ResilientSpring Oct 4, 2023
e26580e
Merge pull request #205 from ResilientSpring/SP7
ResilientSpring Oct 4, 2023
cc0f63f
Committed on or around 2023/10/04
ResilientSpring Oct 4, 2023
fdd7c3d
Committed on or around 2023/10/04
ResilientSpring Oct 4, 2023
bbc4cbc
Merge pull request #206 from ResilientSpring/SP7
ResilientSpring Oct 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions 29 Chapter7/IncompatibleRef.java
Original file line number Diff line number Diff line change
@@ -1,38 +1,37 @@
import java.awt.PrintGraphics;

// This will not compile
class X {

int a;

X(int i) {
a = i;
}
}

class Y {
int a ;

Y(int i){

int a;

Y(int i) {
a = i;
}

}

}

public class IncompatibleRef {

public static void main(String[] args) {
// TODO Auto-generated method stub

X x = new X(10);

X x2;

Y y = new Y(5);
x2 = x; // Ok, both of same type.
x2 = y; // Error, not of same type.

x2 = x; // Ok, both of same type.

x2 = y; // Error, not of same type.

}

Expand Down
48 changes: 48 additions & 0 deletions 48 Chapter7/theoretical/SupSubRef.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package theoretical;

//A superclass reference can refer to a subclass object.

class X {

int a;

public X(int i) {
a = i;
}
}


class Y extends X {

int b;

public Y(int i, int j) {

super(j);
b = i;
}
}


public class SupSubRef {

public static void main(String[] args) {

X x = new X(10);
X x2;
Y y = new Y(5, 6);

x2 = x; // OK, both of same type.
System.out.println("X2.a: " + x2.a);
System.out.println("x.a: " + x.a);

x2 = y; // still ok because Y is derived from X.
System.out.println("X2.a: " + x2.a);

// X references know only about X members
x2.a = 19; // OK
// x2.b = 27; // Error, X does not have a b member.

}

}
51 changes: 51 additions & 0 deletions 51 Chapter8/Interface/Interfaces_Can_Be_Extended.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package Interface;

// One interface can extend another.
interface A{

void meth1();
void meth2();
}

// B now includes meth1() and meth2() - it adds meth3().
interface B extends A{ // B inherits A.
void meth3();
}

// This class must implement all of A and B
class MyClass implements B{

@Override
public void meth1() {
// TODO Auto-generated method stub
System.out.println("Implement meth1(). ");
}

@Override
public void meth2() {
// TODO Auto-generated method stub
System.out.println("Implement meth2(). ");
}

@Override
public void meth3() {
// TODO Auto-generated method stub
System.out.println("Implement meth3(). ");
}
}


public class Interfaces_Can_Be_Extended {

public static void main(String[] args) {
// TODO Auto-generated method stub

MyClass obMyClass = new MyClass();

obMyClass.meth1();
obMyClass.meth2();
obMyClass.meth3();

}

}
98 changes: 98 additions & 0 deletions 98 Chapter8/Interface/Using_Interface_References.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package Interface;

// An interface specifies what to do, not how to do.
interface Seriess{
int getNext();
void reset();
void setStart(int x);
}

class ByTwoss implements Seriess{

int start;
int value;

public ByTwoss() {
start = 0;
value = 0;
}

@Override
public int getNext() {
value += 2;
return value;
}

@Override
public void reset() {
value = start;

}

@Override
public void setStart(int x) {
// TODO Auto-generated method stub
start = x;
value = x;
}

}


class ByThreess implements Seriess{

int start;
int value;

public ByThreess() {
start = 0;
value = 0;
}

@Override
public int getNext() {

value += 3;

return value;
}

@Override
public void reset() {
// TODO Auto-generated method stub
value = start;
}

@Override
public void setStart(int x) {
// TODO Auto-generated method stub
start = x;
value = x;
}

}


public class Using_Interface_References {

public static void main(String[] args) {

ByTwoss twoOb = new ByTwoss();
ByThreess threeOb = new ByThreess();
Seriess ob;

for (int i = 0; i < 5; i++) {

ob = twoOb;

System.out.println("Next ByTwos value is " + ob.getNext());

ob = threeOb;

System.out.println("Next ByThrees value is " + ob.getNext());

}

}

}
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.