Informative how to spend life,Entertain how to Fun, Feelings of happiness, relaxation and enjoyment. jobs, tutoriasl
Monday, 30 June 2014
Friday, 27 June 2014
Java Inheritance example
Here is the detail with code for inheritance
for super class
we name it Employee
as
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaemployee;
/**
*
* @author jawadmahmood
*/
public class Employee {
protected String name;
protected int id;
/// creating the parameterized constructor
public Employee(int id , String name )
{
this.name = name ;
this.id = id;
}
// defautl constructor
public Employee()
{
this(100 , "NOt defined");
}
// set id
public void setId(int id)
{
this.id = id;
}
// get id
public int getId()
{
return id ;
}
// set name
public void setName(String name )
{
this.name = name;
}
// get name
public String getName()
{
return name;
}
public void dislpay()
{
System.out.println("In Employee Display method");
System.out.println("Employee id " + id + " and name is " + name);
}
public String toString()
{
System.out.println("In employee the record is ");
return "id " + id + "name: " + name;
}
}
for super class
we name it Employee
as
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaemployee;
/**
*
* @author jawadmahmood
*/
public class Employee {
protected String name;
protected int id;
/// creating the parameterized constructor
public Employee(int id , String name )
{
this.name = name ;
this.id = id;
}
// defautl constructor
public Employee()
{
this(100 , "NOt defined");
}
// set id
public void setId(int id)
{
this.id = id;
}
// get id
public int getId()
{
return id ;
}
// set name
public void setName(String name )
{
this.name = name;
}
// get name
public String getName()
{
return name;
}
public void dislpay()
{
System.out.println("In Employee Display method");
System.out.println("Employee id " + id + " and name is " + name);
}
public String toString()
{
System.out.println("In employee the record is ");
return "id " + id + "name: " + name;
}
}
and for sub class we developed with the name of Teacher as
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaemployee;
/**
*
* @author jawadmahmood
*/
public class Teacher extends Employee{
private String qual;
// default constructor
public Teacher()
{
/// implicit call to superclass default constructor
qual = "";
}
// parameterized constructor
public Teacher(int i , String n , String q)
{
super(i , n);
qual = q;
}
public void setId( int id)
{
this.id = id;
}
public int getId()
{
return id;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
/// display the teacher information
public void display()
{
System.out.println("In teacher the ");
super.dislpay();
System.out.println("The teacher qualificationn " + qual );
}
public String toSting()
{
System.out.println("In teacher class");
String emp = super.toString();
return emp + "The qualifaction is " + qual ;
}
}
the we will it to main function
and the main function is this
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaemployee;
/**
*
* @author jawadmahmood
*/
public class JavaEmployee {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println("Making object ");
Employee e = new Employee (88 , "jawad");
System.out.println("Making object of teacher");
Teacher t = new Teacher(9 , " hamza khan ", "Phd");
/// display the method of employee
e.dislpay();
// display teacher methed
t.dislpay();
}
}
and the out put will as
java inheritance
For inheritance we use the word EXTENDS in small case
like
public Employee extends Doctor
{
// do with the class what ever you want
}
in this upper line
Employee is the parent class and Doctor is the sub class of Employee
and the word extends is use for inheritance
in next post we will discuss in detail
like
public Employee extends Doctor
{
// do with the class what ever you want
}
in this upper line
Employee is the parent class and Doctor is the sub class of Employee
and the word extends is use for inheritance
in next post we will discuss in detail
Thursday, 26 June 2014
Happiness of life: java creating object constructor
Happiness of life: java creating object constructor: First of all you will have to create file with .java extension with class name same with the file name as show in the program given ...
java creating object constructor
First of all you will have to create file with .java extension with class name same with the file name
as show in the program given
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapptwo;
/**
*
* @author jawadmahmood
*/
public class Student {
private String name ;
private int rollNo ;
public void setName(String name)
{
this.name = name;
}
public void setRollNo(int rollNo)
{
if(rollNo > 0 )
{
this.rollNo = rollNo;
}
else
{
this.rollNo = 100;
}
}
public String getName()
{
return name ;
}
public int getRollNo()
{
return rollNo;
}
public Student()
{
name = "not defined";
rollNo = 500;
}
public Student(String name , int rollNo)
{
setName(name);
setRollNo(rollNo);
}
public Student(Student s)
{
name = s.name;
rollNo = s.rollNo;
}
public void print()
{
System.out.println("Student name: " + name + " , RollNo " + rollNo);
}
}
as image given
as show in the program given
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapptwo;
/**
*
* @author jawadmahmood
*/
public class Student {
private String name ;
private int rollNo ;
public void setName(String name)
{
this.name = name;
}
public void setRollNo(int rollNo)
{
if(rollNo > 0 )
{
this.rollNo = rollNo;
}
else
{
this.rollNo = 100;
}
}
public String getName()
{
return name ;
}
public int getRollNo()
{
return rollNo;
}
public Student()
{
name = "not defined";
rollNo = 500;
}
public Student(String name , int rollNo)
{
setName(name);
setRollNo(rollNo);
}
public Student(Student s)
{
name = s.name;
rollNo = s.rollNo;
}
public void print()
{
System.out.println("Student name: " + name + " , RollNo " + rollNo);
}
}
as image given
and will have to create the class with main method
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapptwo;
/**
*
* @author jawadmahmood
*/
public class JavaAppTwo {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println("Welcom");
Student s1 = new Student("ali" , 15);
Student s2 = new Student();
Student s3 = new Student("akhtar khan ", 55);
s1.print();
s2.print();
s3.print();
}
}
image
now run the program
and you will get the result as
Wednesday, 25 June 2014
Java Program basic with dialog box
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package java2;
/**
*
* @author hamzakhanzadah
*/
import javax.swing.*;
public class Java2 {
private static String JOptionsPane;
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
// JOptoinPane for graphically Representation
String input = JOptionPane.showInputDialog("Please enter the number ");
int number = Integer.parseInt(input);
JOptionPane.showMessageDialog(null, "The message is " + number );
}
}
Here is the basic program for the dialog box in which dialog box is open and we enter the number
and the number is shown in the message box ...
JOptionPane is used to show graphically
as the screenshots are showing below
Tuesday, 24 June 2014
Command line in mac
Command line in mac is know as
Terminal
we can use the TERMINAL in these steps
first of all we will have to go to the FINDER available in the dock
then go to the APPLICATIONS
from there you will have to the UTILITIES
in UTILITIES there will be a TERMINAL
CLICK ON THE TERMINAL
AND you will see the screen where you can text for command
Terminal
we can use the TERMINAL in these steps
first of all we will have to go to the FINDER available in the dock
then go to the APPLICATIONS
from there you will have to the UTILITIES
in UTILITIES there will be a TERMINAL
CLICK ON THE TERMINAL
AND you will see the screen where you can text for command
Sunday, 22 June 2014
Happiness of life: Screenshot in mac
Happiness of life: Screenshot in mac: You can screenshot of a specific area of your desktop in Mac OS Pull up the application, window, or other item you'd like to...
Tuesday, 17 June 2014
Apple Swift Programming
Now APPLE developers will have to develop the apple application in SWIFT programming.
The developers will have to upgrade for the swift programming.
Apple have sent the documentation for the swift language.
Here is the link for the
APPLE DEVELOPERS
https://developer.apple.com/swift/
The swift language like more like the c and objective c .
From this link the developer can read the whole info.
The developers will have to upgrade for the swift programming.
Apple have sent the documentation for the swift language.
Here is the link for the
APPLE DEVELOPERS
https://developer.apple.com/swift/
The swift language like more like the c and objective c .
From this link the developer can read the whole info.
wordpress for mobile device check
In wordpress there is check for mobiles
like android iphone tablet and like others
if you want to know if the device is mobile you can use the function
wp_is_mobile();
Through this check you apply it for layout design
or functionality for mobile you can use this function
like
if( wp_is_mobile())
{
//// the conditional code will go here
}
Subscribe to:
Posts (Atom)