12. An example of object and class method?

class Rectangle {                 int length,width;                 void getData(int x,int y)                 {                                 length=x;                                 width=y;                 }                 int rectArea()                 {                                 int area=length*width;                                 return (area);                 } } class RectArea {                 public static void main(String args[])                 {                                 int area1,area2;                                 Rectangle rect1=new Rectangle();                                 Rectangle rect2=new Rectangle();... Continue Reading →


Output method: –

Output method: - A java language provides two methods to display output on screen. These two methods are – (1) print(); and (2) println(); method. Print() method: - This method since information into a buffer. This buffer is not flushed until a new line character is sent. As a result, the print() method prints output... Continue Reading →

11. Write a program in java to input 10 integer number. Find a largest number out of 10 input numbers?

import java.io.DataInputStream; class Largest {                 public static void main(String args[])                 {                                 DataInputStream in=new DataInputStream(System.in);                                 int l=0,j=0,c=0;                                 try                                 {                                                 System.out.println("Enter Ten Integer Number : ");                                                 for(c=0;c<10;c++)                                                 {                                                                 j=Integer.parseInt(in.readLine());                                                                 if(j>l)                                                                                 l=j;                                                 }                                 }                                 catch(Exception e) {}                                 System.out.println("Largest Number = "+l);                ... Continue Reading →

Class definition: –

Class definition: - A class is a user defined data type with a template that serves to defines it properties. Once the class type has been defined, we can create variables of that type using declaration that are similar to basic type declaration. In java, these variables are termed as instances of classes, which are... Continue Reading →

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: