0% found this document useful (0 votes)
18 views6 pages

Public Class Public Static Void Int Int Long Long: Page 1 of 6

The document discusses object-oriented programming in Java and includes examples of unary operators, bitwise operators, relational operators, increment/decrement operators, and ternary operators. Code snippets are provided to demonstrate the use of various arithmetic, logical, and conditional expressions in Java. Key concepts covered include unary operators like addition/subtraction, bitwise AND/OR/XOR, string comparison, post-increment/decrement, complement operator, and the ternary conditional operator.

Uploaded by

Fajar Nur Rohmat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views6 pages

Public Class Public Static Void Int Int Long Long: Page 1 of 6

The document discusses object-oriented programming in Java and includes examples of unary operators, bitwise operators, relational operators, increment/decrement operators, and ternary operators. Code snippets are provided to demonstrate the use of various arithmetic, logical, and conditional expressions in Java. Key concepts covered include unary operators like addition/subtraction, bitwise AND/OR/XOR, string comparison, post-increment/decrement, complement operator, and the ternary conditional operator.

Uploaded by

Fajar Nur Rohmat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

PEMROGRAMAN BERORIENTASI OBJEK

1.public class unary {


public static void main(String[] args) {
int i= 20;
int j=30;
long x=6;
long y=3;
System.out.println("Aritmatika");
System.out.println("===========");
System.out.println ("i= " .... " j= "....." x= " .... " y= " .....);
System.out.println
System.out.println
System.out.println
System.out.println
System.out.println
System.out.println
System.out.println
System.out.println
System.out.println
System.out.println
System.out.println

(" i +
(" i (" x *
(" x /
(" i *
(" i /
(" i %
(" i /
("");
(" i =
(" j =

j
j
y
y
x
x
x
x

=
=
=
=
+
+
-

"
"
"
"
y
y
y
y

+
+
+
+
*
/
*
%

.......);
.......);
.......);
.......);
j = " + ...............);
j = " + ...............);
j = " + ...............);
j = " + ...............);

System.out.println
System.out.println
System.out.println
System.out.println
System.out.println
System.out.println
System.out.println
}
}

("mengganti nilai variable");


(" i= i + x = " + .........);
(" j = j * y = " + ........);
("");
(" i = " + .......);
(" j = " + .......);
(" i + j = " + .......);

" + .......);
" + .......);

Page-1-1 of 6

2. public class And {


public static void main(String[] args) {
int a = 6; //110
int b = 4; //100
boolean[] all = { false, true };
//bitwise AND
.......... ;
//bitwise OR
...........;
System.out.println("AND and OR");
System.out.println("===========");
System.out.println("c = "......); //4
System.out.println("d= " ......); //6
System.out.println("===========");
if(..........................)
{
System.out.println("yes");
}
if(..........................)
{
System.out.println("no");
}
//XOR
System.out.println("===========");
System.out.println("XOR");
System.out.println("===========");
for (.......................) {
for (...............) {
.................;
System.out.println(......." ^ "........" = ".......);
}
}
}
}

Page-1-2 of 6

3. public class instance{


public static void main(String[] args) {
int i = 64;
System.out.println(.......................);
System.out.println("=====================");
int max = Integer. .............. .length();
int j;
for (.......................) {
.........;
System.out.println(.......................);
System.out.println("=====================");
}
}
}

Page-1-3 of 6

4. import java.util.*;
public class relasi {
public static void main(String[] args) {
String s1="Cat";
String s2="Dog";
String s3="Cat";
String s4="Dog";
System.out.println("Relasi");
System.out.println("===========");
if (s1.compareTo(s2) !=0)
System.out.println("cat no dog");
if (s1.compareTo(s3) ==0)
System.out.println("cat is cat");
if (s2.compareTo(s4) ==0)
System.out.println("dog is dog");
}
}

Page-1-4 of 6

5. public class Post {


public static void main(String[] args){
int i = 3;
......;
System.out.println(i); //4
......;
System.out.println(i); //5
......; // 6
System.out.println(i); // 4
......;
System.out.println(...........); //3
System.out.println(...........); //8
System.out.println(...........); //14
System.out.println("================");
............;
.................;
.................;
.................;
System.out.println(....); //38
System.out.println(....); //29
System.out.println("================");
System.out.println("================");
int x = ~3;
int y = ~4;
System.out.println("complement = " + .....); //-4
System.out.println("complement = " + .....); //-9
}
}

Page-1-5 of 6

6. public class ternary


{
public static void main(String[] args)
{
// min value
int minVal, a=3, b=2;
........................;
System.out.println("min = "...........);
// absolute value
a = -10;
int absValue = (......................;
System.out.println("abs = " ..........);
// result value 1.0
float result = true ? ................;
System.out.println(...................);
// result value "Sorry Bro, salah"
String s = false ? "............................." ;
System.out.println(.........);
// example string
int x = 5;
String out = "..................................." ;
System.out.println(..............);
}
}

Page-1-6 of 6

You might also like