Posts

Showing posts from June, 2021

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 ();

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

Java Array Problems

Java Program to Find Largest Number in an array public class A_MaxNumInArray { public static void main ( String [] args ) { int [] array = { 4 , - 3 , 7 , 100 , 89 , 45 , 99 }; //Find the largest number in this array. //Logic- // 1. We consider the 1st number highest(int max). // 2. store values of array in j after each ilteration. // 3. if j>max then max=j. int max = Integer . MIN_VALUE ; for ( int i = 0 ; i < array.length;i ++ ){ int j = array[i]; if (j > max){ max = j; } } System . out . println ( "The max number is: " + max); } } Java Program to Find Smallest Number in an array public class A_MinNumInArray { public static void main ( String [] args ) { int [] array = { 100 , 39 , - 90 , 45 , 3 , 1 , 57 }; //Find the minimum number from the array. //Logic- //1. let 1st number be minimum(in