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
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package Abstract_Methods_and_Classes;

public class Abstract_classes {

// An abstract class is a class that is declared "abstract"—it may or may not include abstract methods.

// Abstract classes cannot be instantiated, but they can be subclassed.

// When an abstract class is subclassed,
// the subclass usually provides implementations for all of the abstract methods in its parent class.
// However, if it does not, then the subclass must also be declared abstract.

// Reference:
// https://docs.oracle.com/javase/tutorial/java/IandI/abstract.html

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package Abstract_Methods_and_Classes;

public abstract class Abstract_methods {

// An abstract method is a method that is declared without an implementation (without braces,
// and followed by a semicolon), like this:
abstract void moveTo(double deltaX, double deltaY);

}
26 changes: 26 additions & 0 deletions 26 Oracle_Java_Tutorials/Classes_and_Objects/Exercise2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package Classes_and_Objects;

class NumberHolder {
public int anInt;
public float aFloat;

public NumberHolder(int a, float b) {
anInt = a;
aFloat = b;
}
}

public class Exercise2 {

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

NumberHolder symposiumNumberHolder = new NumberHolder(1, 2);

System.out.println(symposiumNumberHolder.anInt + symposiumNumberHolder.aFloat);

System.out.println(symposiumNumberHolder.anInt + ", " + symposiumNumberHolder.aFloat);

}

}
29 changes: 29 additions & 0 deletions 29 Oracle_Java_Tutorials/Classes_and_Objects/Question1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package Classes_and_Objects;

class IdentifyMyParts {
public static int x = 7; // class variable.
public int y = 3; // instance variable.
}

public class Question1 {

public static void main(String[] args) {
// TODO Auto-generated method stub
IdentifyMyParts a = new IdentifyMyParts();
IdentifyMyParts b = new IdentifyMyParts();

a.y = 5;
b.y = 6;

a.x = 1;
b.x = 2;

System.out.println("a.y = " + a.y);
System.out.println("b.y = " + b.y);
System.out.println("a.x = " + a.x);
System.out.println("b.x = " + b.x);
System.out.println("IdentifyMyParts.x = " + IdentifyMyParts.x);

}

}
43 changes: 43 additions & 0 deletions 43 Oracle_Java_Tutorials/Inheritance/Question1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package Inheritance;

class ClassA {

public void methodOne(int i) {

}

public void methodTwo(int i) {

}

public static void methodThree(int i) {

}

public static void methodFour(int i) {

}
}

class ClassB extends ClassA {

public static void methodOne(int i) {

}

public void methodTwo(int i) {

}

public void methodThree(int i) {

}

public static void methodFour(int i) {

}
}

public class Question1 {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package Inheritance;

class ChessAlgorithm__{
enum ChessPlayer{
BLACK, WHITE
}

final ChessPlayer getFirstPlayer() {
return ChessPlayer.BLACK;
}
}

public class Writing_final_classes_and_methods6 {

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

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package Inheritance;

import Inheritance.ChessAlgorithm___.ChessPlayer;

class ChessAlgorithm___{
enum ChessPlayer{
BLACK, WHITE
}

final ChessPlayer getFirstPlayer() {
return ChessPlayer.BLACK;
}
}

public class Writing_final_classes_and_methods7 {

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

ChessAlgorithm___ returnType = new ChessAlgorithm___();

ChessPlayer symposiumChessPlayer = returnType.getFirstPlayer();

System.out.println(symposiumChessPlayer);

}

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