INHERITANCE Its just simply say childs can use or access their parent property. It means a child class object can access the super class methods.There is a important key word used in this concept is extends.Ex: class child extends father {} It represents IS-A relationshipex:Dhoni IS-A Cricketer,R15 IS-A Bike. Uses are code reusability, method overriding.Continue reading “Inheritance”
Author Archives: selvaklt
System.in,System.out and Scanner
System.in is an InputStream which is typically connected to keyboard input of console programs. System.in is not used as often since data is commonly passed to a command line Java application via command line arguments, or configuration files. In applications with GUI the input to the application is given via the GUI. At times youContinue reading “System.in,System.out and Scanner”
CONSTRUCTOR
ConstructorA constructor in Java is a special method that is used to initialize objects. The constructor is called when an object of a class is created. It can be used to set initial values for object attributes: constructor program example:package constructorexcercise; public class Payticketprice {int paise;public Payticketprice() {paise=100; } Result:Payticket price 100 Note: constructor nameContinue reading “CONSTRUCTOR”
OOPS
Today we gonna create small project to calculate hsc marks. package Oops; import java.util.Scanner; public class Hscmarkcalculator { int noofsubject; int marks; int total; public static void main(String[] args) { // TODO Auto-generated method stub Hscmarkcalculator hsc=new Hscmarkcalculator(); hsc.getmark();//method calling statement hsc.Calculategrade();// method calling statement } private void Calculategrade() {//method Body // TODO Auto-generated methodContinue reading “OOPS”
Pattern programs
Today we gonna see some pattern programs. In this program we print three row and three column. package Pattern; public class Pattern { public static void main(String[] args) { // TODO Auto-generated method stub for (int no=1;no<=3;no++) { for (int col=1;col<=3;col++) { System.out.print(no); } System.out.println(); } } } Result: 111 222 333 In this programContinue reading “Pattern programs”
ARRAY PROGRAMS
Today we gonna see some array programs.In below program we gonna see how many times a number present in the array.package Array; public class FindnoOfTimeaNumberPresent { } Result:2 In this program we using linear search to find given number.package Array; public class LinearSearch { int a[]= {1,2,3,4,5};for(int i=0;i<a.length;i++) {if(4==a[i]) {System.out.println(” I GOT IT”); }} }Continue reading “ARRAY PROGRAMS”
ARRAY
Today we gonna see array. What is array? Collection of similar (datatype) elements stored continuously. It is index based. Index starts from 0(zero). Index ends at length-1. In java array is an object Array declaration. datatype[] referencename= new datatype[int] variable array length is integer ex: array int[] arr= new int[6] A0 A1 A2 A3 A4Continue reading “ARRAY”
NUMBER PROBLEMS3
In this time, we see the programs like armstrong number,binary to decimal,decimal to binary,fibonacci series,greatest common divisor, least common divisor,neon number,perfect number,spy number, sum of digits. ARMSTRONG NUMBEER It is the number with sum of each digits multiplied itself three times and its equal to the given number. Ex: 153 3–> 3*3*3=27 5–>5*5*5=125 1–>1*1*1=1 total=27+125+1=153Continue reading “NUMBER PROBLEMS3”
NUMBER PROBLEMS 2
Here we gonna see some simple interesting programs are modulus,multiple increment, narrow casting,number reverse, or operator, palindrome,qube,reverse order, smallest divisor,square root,sum of digits, swaping out,table 3 and their results. MODULUS package selva.day1; public class Modulus { public static void main(String[] args) { // TODO Auto-generated method stub int no=1; while(no<=50) { if(no%3==0) { if(no%5==0) {Continue reading “NUMBER PROBLEMS 2”
Number problems
Today we gonna see some interesting number problems program like increament,number reverse, modulus etc., ForCondition package excercise; public class ForCondition { public static void main(String[] args) { // TODO Auto-generated method stub for(;;) { System.out.println(“hi”); break; } } } RESULT: hi ForLoop package excercise; public class ForLoop { public static void main(String[] args) { intContinue reading “Number problems”