• Tidak ada hasil yang ditemukan

Praktikum PBO

N/A
N/A
Nguyễn Gia Hào

Academic year: 2023

Membagikan "Praktikum PBO"

Copied!
5
0
0

Teks penuh

(1)

Praktikum PBO

Pengambilan Keputusan dan

Pengulangan Proses

(2)

Soal 1

public void foo( boolean a, boolean b) {

if( a ) {

System.out.println("A"); /* Line 5 */

}

else if(a && b) /* Line 7 */

{

System.out.println( "A && B");

}

else /* Line 11 */

{

if ( !b ) {

System.out.println( "notB") ; }

else {

System.out.println( "ELSE" ) ; }

} }

A. Jika a true dan b true maka output adalah "A && B"

B. Jika a true dan b false maka output adalah "notB"

C. Jika a false dan b true maka output adalah "ELSE"

D. Jika a false dan b false maka output adalah "ELSE"

(3)

Soal 2

• public class Ebb {

• static int x = 7;

• public static void main(String[] args) {

• String s = "";

• for (int y = 0; y < 3; y++) {

• x++;

• switch (x) {

• case 8:

• s += "8 ";

• case 9:

• s += "9 ";

• case 10: {

• s += "10 ";

• break;

• }

• default:

• s += "d ";

• case 13:

• s += "13 ";

• }

• }

• System.out.println(s);

• }

• static {

• x++;

• }

• }

• Bagaimana output program ?

• A. 9 10 d

• B. 8 9 10 d

• C. 9 10 10 d

• D. 9 10 10 d 13

(4)

Soal 3

• public class Label2 {

• public static void label2(){

• int i=0;

• outer :

• while(true){

• i++ ;

• inner :

• for(int j=0;j<10;j++){

• i+=j ;

• if ( j==3)

• continue inner ;

• break outer ;

• }

• continue outer ;

• }

• System.out.println(i);

• }

• }

• Bagaimana output program ?

– 1

– 2

– 3

– 4

(5)

Soal 4

• Terdapat program seperti dibawah ini :

• public class Wind {

• public static void main(String[] args) {

• foreach:

• for (int j = 0; j < 5; j++) {

• for (int k = 0; k < 3; k++) {

• System.out.print(" " + j);

• if (j == 3 && k == 1) {

• break foreach;

• }

• if (j == 0 || j == 2) {

• break;

• }

• }

• }

• }

• }

• Bagaimana output program ?

• A. 0 1 2 3

• B. 1 1 1 3 3

• C. 0 1 1 1 2 3 3

• D. 1 1 1 3 3 4 4 4

Referensi

Dokumen terkait

After the issuance of this regulation, there is an expansion of authority, the Elections Supervisory Agency, which is given quasi-judicial authority in handling administrative

tightening torque of housing nut 30 Nm Electrical connection Connectors, M12 × 1 Pressure resistance 20 bar Process connection G 1/4" Features ■Flow sensor for liquid media