What is the output of this program? (or, can it be compiled)?


Ans: The output of the above program is shown below



Download 1,04 Mb.
bet2/4
Sana22.06.2021
Hajmi1,04 Mb.
#73073
1   2   3   4
Bog'liq
BasicJavaTask5 homework

Ans: The output of the above program is shown below:





  1. What is the output? Explain it.

public class OOP {

public static void main(String[] args) {

OOP oop1 = new OOP();

OOP oop2 = new OOP();

System.out.print(oop1==oop2);

oop2 = oop1;

oop1 = new OOP();

System.out.print(oop1!=oop2); }}



Ans: The output of above code is given below:






  1. Given these two Java files. What printed (or did any exceptions appear)? Explain it.



// D.java

public class D {

public void printMethod() {

System.out.println("Printed in Superclass.");

}

}





// C.java

public class C extends D {

public void printMethod() {

System.out.println("Printed in Subclass.");

super.printMethod();

}

public static void main(String[] args) {



C c = new C();

c.printMethod();

}

}
Ans: The output of the above program is shown below:



There is no any exception in the code. The child class inherits function of parent class.




  1. Complete the following source code! Said that method Count() accepts three parameters: an integer (int n) and two matrices (int[][] x dan int[][] y) with size n x n. Count() method will return a new matrix by adding matrix x and matrix y without changing it.




public static int[][] Count(int n, int[][] x, int[][] y){



}


Ans: The output of the above code is given below:




  1. Given a program: HotelGuestGUI, as below.




Before interaction



Registration with empty Name and NID



Registration with empty NID



Registration with empty Name




Registration done successfully. Pay attention to Status and Room Type, too.

Complete the following source code of HotelGuestGUI.java (see the blank spots and code sections).



public void start(Stage mainStage) throws Exception {
GridPane x = new GridPane();

x.setAlignment(Pos.CENTER);

x.setVgap(10);

x.setHgap(10);

Label y = new Label("Such a lovely place, such a lovely face");

HBox b = new HBox(y);

b.setAlignment(Pos.CENTER);

x.add(b, 0, 0, 2, 1);

Label z = new Label("Guest Name");

x.add(z, 0, 1);

TextField a = new TextField();

x.add(a, 1, 1);

Label c = new Label("Guest NID");

x.add(c, 0, 2);

TextField d = new TextField();

x.add(d, 1, 2);

Label j = new Label("Status");

x.add(j, 0, 3);

CheckBox e = new CheckBox("VIP?");

x.add(e, 1, 3);

Label k = new Label("Room Type");

x.add(k, 0, 4);

.................... i = new ....................();

i.getItems().add("Standard");

i.getItems().add("Executive");

i.getItems().add("Heaven");

i.setValue("Standard");

x.add(i, 1, 4);

Button f = new Button("Register");

x.add(f, 1, 5);

Text g = new Text("");

HBox h = new HBox(g);

h.setAlignment(Pos.CENTER);

x.add(h, 0, 6, 2, 1);


f. .................... (ev -> {

// complete the code fully here

});


Scene sc = new Scene(x, 280, 240);

mainStage.setScene(sc);

mainStage.setTitle("Hotel California");

mainStage.show();

}





  1. What is the output?

int val;

String s = "DDP";

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

s = i % 3 == 1 ? s.toUpperCase() : s.toLowerCase();

}

s.toUpperCase();



switch(s) {

case "DDP":

val = 1; break;

case "ddP":

val = 2; break;

case "DDp":

val = 3;

default:

val = 4; break;

}

System.out.println(val);



Ans: The output of the above code is shown below:





  1. Explain the following class diagram and source code example. What is the relationship between manager and employee?





  1. Explain the differences of Java GUI: AWT, Java Swing, and JavaFX!

Ans:


Download 1,04 Mb.

Do'stlaringiz bilan baham:
1   2   3   4




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish