Page 138 - Computer science 868 Class 12
P. 138

System.out.println("Twice : " +tw);
                          System.out.println("Thrice : " +th);
                         }
                      }


                  4.11 ADVANTAGES AND DISADVANTAGES OF JAVA
              Java has many advantages that made it a very user–friendly programming language. They are discussed below.
              •  Machine-independent: It is designed in such a way that it can execute on any computer regardless of the Operating
                 System installed in it. This is why it became a very important language for developing web-related programs.
              •  Simple programming language: Scripting, compiling and debugging make the Java program simple and easy. It
                 follows all the qualities of OOP such as creating modular programs and reusable codes etc.

              •  Multi-functional language: Different types of applications can be developed using Java. Command-line programs,
                 Applets, and Swing windows (GUI widget toolkit) are some of the common types.
              •  Economical to maintain: Developing and maintenance of these programs are cheap as we can execute them on any
                 computer with any Operating System installed on it. Thus, it also supports the portability feature.
              •  Automatic garbage collection: Automatic memory management in Java instructs Java Virtual Machine (JVM) to
                 remove unused objects automatically when not required.

              •  Distributed language: Java can share data and programs among different computers which help to improve the
                 performance and efficiency of the system. For example, Remote Method Invocation, Socket programming and
                 CORBA technology are supported by Java.

              •  Interactive programming: Java programming allows us to develop interactive Internet programs so that the user
                 can give his/her choices while browsing through a web page.
               •  Versatile: Java programming language is versatile as it can be used to develop programs of various kinds and
                 provides solutions for a variety of devices such as mobiles, PCs with networking, etc.
              As a programming language, it also has some disadvantages which are listed below:

              •  Time-consuming  process: Since  Java runs  in  web technology,  the server  sends  the compiled  program which
                 gets interpreted in the client machine by JVM to convert it into a machine-dependent language. This makes Java
                 significantly slower than other languages like C or C++. Moreover, the garbage collector in Java consumes more CPU
                 time and leads to poor performance.

              •  No attractive appearance: Though there are many GUI builders in Java that create a graphical interface, they are
                 not appropriate and create many discrepancies while in use.
              •  No backup facility: Java does not provide any options for backing up data which is one major reason for low ratings
                 among users.
              •  Require more amount of space for execution: The requirement for memory space is much higher as compared to
                 other languages like C and C++.


                  4.11 BASIC INPUT/OUTPUT USING SCANNER AND PRINTER CLASSES FROM JDK
              The Printer class is not a standard class in the Java Development Kit (JDK). For printing output in Java, you can use the
              System.out.println method directly, which is the standard way to print output to the console.

              Here’s an example:
                  public class BasicOutputExample
                   {

                136136  Touchpad Computer Science-XII
   133   134   135   136   137   138   139   140   141   142   143