Introduction to Object Oriented Programming in Java

1.Class- Class is the blue print or boiler plate of our project. It consists of attributes(Colour, names and model) and non static methods(functions like turnOn( ); etc) of objects. Microphone Class //Microphone class public class CreatingClass { //Atrributes String name = "sony" ; String colour = "Blue" ; int model = 123 ; //Methods public void turnOn (){ System . out . println ( "Turned on" ); } public void adjustVol (){ System . out . println ( "Volume adjusted" ); } public void turnoff (){ System . out . println ( "Turned off" ); } public void description (){ System . out . println ( this .name + " is my brand. " + "My colour is " + this .colour); } } Main class public class CreatingClassMain { public static void main ( String [] args ) { CreatingClass Microphone1 =new CreatingClass (); Microphone1. turnoff ();

Java Number Program

Comments

Popular posts from this blog

Java Array Problems

Introduction to Object Oriented Programming in Java