Sei sulla pagina 1di 4

However, some extensive advantages of Java remain:

Garbage collection built into the language. Synchronization built into the language Threading built into the language A lot more debugging information rolled into the binaries, making crashes easier to debug Late linking makes some development and deployment smoother. Platform-independent binaries, and rigorous code checking, make it possible to safely deploy code within another process (e.g. user-supplied builtins, application servers)

Below is the main difference between the 3 components:


Concrete class - Provides implementation for all its methods & also for methods from extended abstract classes or implemented interfaces Abstract class - Does not provide implementation for one or more of its methods Interface - Does not provide implementation for any of its methods

You can use rectangular arrays to store data, which can then be used in literally infinite amounts of ways. An example would be a table of students grades, with M being student IDs and N being their grades. On the other hand, jagged arrays are arrays that are not rectangular in shape; that is, at least one row has a different amount of columns than the rest. Object-oriented programming (OOP) may include features such as data abstraction, encapsulation, messaging, modularity, polymorphism, and inheritance. An applet is a small Internet-based program written in Java, a programming language for the Web, which can be downloaded by any computer. The applet is also able to run in HTML. The applet is usually embedded in an HTML Definition of: Java application A Java program that is run stand alone. The Java Virtual Machine in the client or server is interpreting the instructions. Definition of: Java applet A Java program that is downloaded from the server and run from the browser. The Java Virtual Machine built into the browser is interpreting the instructions. In a programming language encapsulation is used to refer to one of two related but distinct notions, and sometimes to the combination[1][2] thereof:

A language mechanism for restricting access to some of the object's components.[3][4] A language construct that facilitates the bundling of data with the methods (or other functions) operating on that data.[

polymorphism in the context of object-oriented programming, is the ability to create a variable, a function, or an object that has more than one form. Inheritance is the capability of a class to use the properties and methods of another class while adding its own functionality.

Overloaded methods are methods with the same name signature but either a different number of parameters or different types in the parameter list Polymorphism is the capability of an action or method to do different things based on the object that it is acting upon. Encapsulation is the ability of an object to be a container (or capsule) for related properties (ie. data variables) and methods (ie. functions)
public class JavaApplication18 { public static void modifybyreference(int[] b) { System.out.println("pass by reference"); for(int i=0;i<b.length;i++) { b[i]+=1; System.out.println(b[i]); } } public static void modifybyvalue(int x) { x+=2; System.out.println("pass by value"+x); } public static void main(String[] args) { int a[]={1,2,3,4,5}; int x=0; for(int i=0;i<a.length;i++) System.out.println(a[i]); modifybyvalue(x); modifybyreference(a); } }************************ public static void main(String[] args) { int mark[]={55,67,70,72,78,80,60,64,84,87}; for(int i=0;i<mark.length;i++){ System.out.print("\t"+mark[i]);} markGrace(mark); System.out.print("\n"+"after grace"+"\n"); for(int i=0;i<mark.length;i++){ System.out.print("\t"+mark[i]); }

} public static void markGrace(int array[]) { for(int i=0;i<array.length;i++) array[i]+=3; }

import java.awt.*; import java.awt.event.*; import javax.swing.*; public class MyApplet extends JApplet implements ActionListener { JButton btn1,btn2; JTextField txt1,txt2; @Override public void init() { // TODO start asynchronous download of heavy resources Container c=getContentPane(); c.setLayout(new FlowLayout()); btn1=new JButton("Factorial"); btn1.addActionListener(this); c.add(btn1); txt1=new JTextField(20); c.add(txt1); btn2=new JButton("Addition"); btn2.addActionListener(this); c.add(btn2); txt2=new JTextField(20); c.add(txt2); } public int ourPow(int base, int power) { if(power==0) return 1; else return base*ourPow(base, power -1); } int result = ourPow(4,3); public int add(int a, int b) { c=a+b; return c; } int c=add(500,200); public void actionPerformed(ActionEvent e) { if(e.getSource()==btn1) txt1.setText(Integer .toString(result)); else txt2.setText(Integer .toString(c)); } }

import javax.swing.*; import java.awt.*; import java.awt.event.*;

public class OurFirstAppletEve extends JApplet implements ActionListener { JButton btn; JTextField txt; public @Override public void init() { Container c = getContentPane(); c.setLayout(new FlowLayout()); btn = new JButton("OK"); btn.addActionListener(this); c.add(btn); txt = new JTextField(20); txt.setEditable(false); c.add(txt); } public int ourPow(int base, int power) { if(power==0) return 1; else return base*ourPow(base, power -1); } int result = ourPow(4,3); public void actionPerformed(ActionEvent ae) { txt.setText(Integer.toString(result)); } /*public void paint(Graphics g) { //Color c = new Color(255,0,0); g.setColor(Color.RED); g.fillRect(80,80,150,100); g.setColor(Color.GREEN); g.drawString("the result is : " + result, 100,100); //g.fillRect(200,200,50,50); }*/ }

Potrebbero piacerti anche