File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+
2+ class Cinema {
3+ private String name ;
4+ public Cinema () {}
5+ public Cinema (String name ) {
6+ this .name =name ;
7+ System .out .print (name );
8+ }
9+ }
10+ public class Q1 {
11+ public Q1 (String movie ) {}
12+ public static void main (String [] args ) {
13+ Cinema cnm =new Cinema ("Hızlı ve Öfkeli 5" );
14+ // System.out.print(new Q1("Another Trilogy").name);
15+
16+ }
17+ /*
18+ * Constructor tanimlamasinda parametreli contructor tanimlamasi yaparken oncelikler default
19+ * contructor olusturulmalidi aksi halde hata verecektir.
20+ * Cevap C
21+ *
22+ */
23+
24+ }
Original file line number Diff line number Diff line change 1+ class Computer {
2+ protected final int process () {return 5 ;}
3+ }
4+ public class Q11 extends Computer {
5+ public final int process () {return 3 ;}
6+
7+ public static void main (String [] args ) {
8+ System .out .print (new Q11 ().process ());
9+ }
10+ /*
11+ * Final olan bir method override edilemez derleme hatasi alınır.
12+ * Cevap C
13+ */
14+
15+ }
Original file line number Diff line number Diff line change 1+ import java .io .FileNotFoundException ;
2+ import java .io .IOException ;
3+
4+ class School {
5+ public int getNumberOfStudentPerClassroom (String ...students ) throws IOException {
6+ return 3 ;
7+ }
8+ public int getNumberOfStudentPerClassroom () throws IOException {
9+ return 9 ;
10+ }
11+ }
12+ public class Q12 extends School {
13+ public int getNumberOfStudentPerClassroom () throws FileNotFoundException {
14+ return 2 ;
15+ }
16+ public static void main (String [] args ) throws IOException {
17+ School school =new Q12 ();
18+
19+ System .out .print (school .getNumberOfStudentPerClassroom ());
20+ }
21+ /*
22+ * Tanimlanan sinif override edildiği icin türetilmis sınıfın degil kendi ozelligi kendi methodunun return type ni dondurur.
23+ * Cevap B
24+ * Cevap B
25+ */
26+
27+ }
Original file line number Diff line number Diff line change 1+ interface Run {
2+ default void walk () {
3+ System .out .print ("Walking and running!" );
4+ }
5+ }
6+ interface Jog {
7+ default void walk () {
8+ System .out .print ("Walking and jogging" );
9+ }
10+ }
11+ public class Q14 implements Run ,Jog {
12+ public void walk () {
13+
14+ System .out .print ("Spriting!" );
15+ }
16+ public static void main (String [] args ) {
17+ new Q14 ().walk ();
18+
19+ }
20+
21+ /*
22+ * Cevap C
23+ */
24+
25+ }
Original file line number Diff line number Diff line change 1+
2+ class Ship {
3+ protected int weight =3 ;
4+ private int height =5 ;
5+ public int getWeight () {return weight ;}
6+ public int getHeigh () {return height ;}
7+ }
8+ public class Q16 extends Ship {
9+ public int weight =2 ;
10+ public int height =4 ;
11+ public void printDetails () {
12+ System .out .print (super .getWeight ()+"-" +super .getHeigh ());
13+ }
14+ public static void main (String [] args ) {
15+ new Q16 ().printDetails ();
16+ }
17+ /*
18+ *Super ifades ust class ta tanımlamıs oldugumuz methodu cagırmakta kullanıyoruz.
19+ *Cevap C
20+ */
21+
22+ }
Original file line number Diff line number Diff line change 1+ abstract class Triangle {
2+ abstract String getDescription ();
3+ }
4+ class RightTriagle extends Triangle {
5+ protected String getDescription () {
6+ return "rt" ;//g1
7+ }
8+
9+ }
10+
11+ public abstract class Q18 extends RightTriagle {//G2
12+ public String getDescription () {return "irt" ;}
13+ public static void main (String [] args ) {
14+ final Triangle shape =new Q18 ();//g3
15+ System .out .print (shape .getDescription ());
16+ /*
17+ * Cevap C
18+ */
19+
20+ }
21+
22+ }
Original file line number Diff line number Diff line change 1+ interface Horn {
2+ public Integer play ();
3+ }
4+ abstract class Woodwind {
5+ public Short play () {
6+ return 3 ;
7+ }
8+ }
9+ public final class Q19 extends Woodwind implements Horn {
10+ public Number play () {
11+ return null ;
12+ }
13+ public static void main (String [] args ) {
14+
15+ }
16+ /*
17+ * Cevap D
18+ */
19+
20+ }
Original file line number Diff line number Diff line change 1+ abstract class Book {
2+ protected static String material ="papyrius" ;
3+ public Book () {}
4+ public Book (String meterial ) {
5+ this .material =meterial ;
6+ }
7+
8+ }
9+ public class Q21 extends Book {
10+ public static String material ="celluose" ;
11+ public Q21 () {
12+ super ();
13+ }
14+ public String getMaterial () {return super .material ;}
15+
16+
17+ public static void main (String [] args ) {
18+ System .out .print (new Q21 ().getMaterial ());
19+
20+
21+ }
22+
23+
24+ /*
25+ * Cevap A
26+ */
27+ }
Original file line number Diff line number Diff line change 1+ interface Sphere { default String getName () { return "Unknown" ; }}
2+
3+ abstract class Planet { abstract String getName (); }
4+
5+ public class Q24 extends Planet implements Sphere {
6+
7+ public Q24 () {super ();}
8+
9+ public String getName () { return "Mars" ; }
10+
11+ public static void main (final String [] probe ) {
12+ System .out .print (((Planet )new Q24 ()).getName ());
13+ }
14+ }
15+ /*
16+ * interfaceler implementes edilir.Abstractlar class lar ise extends edilir.
17+ */
You can’t perform that action at this time.
0 commit comments