Types of the Output in Java

Types of the Java Output

The Output of Computer Programming (not only in Java) basically 4 types,

1) Value based Result (Fixed)
2) Boolean / Logical Result (true/false)
3) Constant based Result
4) Dynamic Result
-----------------------------
1) Value based Result (Fixed)

Arithmetic Operators and some predefined methods return this type of Value based Result...

Example:
System.out.println(10+3);//13
System.out.println(5*6); //30

System.out.println(Math.max(10, 7));//10
-----------------------------
2) Boolean / Logical Result (true/false)

Relational / Comparison Operators return boolean Results, and some predefined methods return this type of Result

Example:

System.out.println(100<99);//false
System.out.println(100>99);//true

System.out.println("ABC".equals("abc"));//false
System.out.println("JAVA".equals("JAVA"));//true 
-----------------------------
3) Constant based Result (Output)

Java Returns Constant based Result in 3-way comparison of Numbers

Result Criteria,
i) if number1 < number2 then -1
ii) if number1 = number2 then 0
iii) if number1 > number2 then 1
----------
Example:

int a=7;
Integer x=a;

System.out.println(x.compareTo(9));//-1
System.out.println(x.compareTo(7));//0
System.out.println(x.compareTo(4));//1
-----------------------------
Java Tutorial
4) Dynamic Results (Output)

i) Generating Random Numbers...
ii) Returning system Date....
---------------------
Example:
//Generate Random Number
System.out.println(Math.random());

//Return System date
Date date = new Date();
System.out.println(date);
-----------------------------

0 comments:

Post a Comment