Friday, 3 January 2014

Write a program to print a Floyd's Triangle

Floyd's Triangle:

Floyd's triangle is a right-angled triangular array of natural numbers, used in computer science education. It is named after Robert Floyd. It is defined by filling the rows of the triangle with consecutive numbers, starting with a 1 in the top left corner:2 34 5 67 8 9 10 and so on....

Program:

import java.util.*;
class FloydsTriangle 
{
public static void main(String[] args)
{
int limit; //this variable is useful for howmany  rows we need?
System.out.println("Enter the limit: ");// asking for limit
Scanner sc=new Scanner(System.in);//taking the input from console
limit=sc.nextInt();//taking the input as integer
int count=1; // for printing purpose
for (int index=1;index<=limit ;index++ ) //this is for number of rows
{
  for (int index1=1;index1<=index ;index1++ ) //in particular row it displays the howmany numbers u want
  {
      System.out.print(count+" "); //printing the number by using the "print" method
  count++;// count increment
  
  }//inner for loop
  System.out.println("");// it is for nextline 
           
            }//outer for loop
}//main
}//class

Output:


C:\Documents and Settings\user1\Desktop\Programs>javac FloydsTriangle.java

C:\Documents and Settings\user1\Desktop\Programs>java FloydsTriangle
Enter the limit:
4
1
2 3
4 5 6
7 8 9 10


Blocking mail from certain senders in gmail

Sometimes you may get unwanted mail that isn't necessarily spam.

While you can't currently block messages from specific addresses or domains, you can set up a filter to send those unwanted messages directly to Trash.
To set up a filter, follow these steps:
  1. Click the down arrow in your search box at the top of the page. A window that allows you to specify your search criteria will appear.
  2. Enter your search criteria. If you want to check that your search worked correctly, click the search button. Clicking the down arrow again will bring the window back with the same search criteria you entered.
  3. Click Create filter with this search at the bottom of the search window.
  4. Choose the action you'd like for these messages by checking the appropriate box. (In this case, we suggest checking "Delete it.")
  5. Click Create Filter.

Wednesday, 4 December 2013

RFC Stands for:

           Request For Comment. it is a document often published regarding engineering standards.

































































Monday, 4 November 2013

Concept of Class and Object simple Example: 


Requirement:
 Write a program to create ‘Student’ class with rollNo and name as two instance variables.
Create two objects student 1, student 2 for the Student class and assign any appropriate values to the objects. Display the Object content on a Console.


Program:
//Student.java
class StudentDetails
{
   int Rollnumber;
   String Name;
   public StudentDetails(int rno,String sname)
{
 Rollnumber=rno;
 Name=sname;
}
public void PrintDetails()
{
System.out.println("..............................\n");
System.out.println("The Student Rollno is:"+Rollnumber);
        System.out.println("The Student Name is:"+ Name);
System.out.println("..............................\n");
}

};//class
public class Student
{


public static void main(String[] args) 
{

  StudentDetails student1=new StudentDetails(1,"Ajay");
  StudentDetails student2=new StudentDetails(2,"Kumar");
  student1.PrintDetails();
  student2.PrintDetails();
}//main

}//class


Output:

..............................

The Student Rollno is:1
The Student Name is:Ajay
..............................

..............................

The Student Rollno is:2
The Student Name is:Kumar
..............................

IS-A Relationship :-
The term it self indicates that "Tight Coupling" of two things.In java Sub class is a part of super class.This IS-A relationship is achieved through Inheritance,Interface concept.
IS-A is a way of saying, "this thing is a type of that thing." For example, a Mustang is a type of horse, so in O O terms we can say, "Mustang IS-A Horse." Subaru IS-A Car. Broccoli IS-A Vegetable (not a very fun one, but it still counts). You express the IS-A relationship in Java through the keyword.

Example :consider following code
public class Parent
{
public void display() //method in super class
{
System.out.println("Display from parent");
}

}//super class


public class Child extends Parent
{
public void childDisplay() //display method in child class
{
System.out.println("Display from child");
}


}//child class

class Demo //it contains the main method
{
public static void main(String[] args)
{
Child ch1=new Child();
Demo d=new Demo();
d.doDisplay(ch1);
}
public void doDisplay(Parent p)
{
p.display();
}
}//demo class


output:

 Display From Parent                        
                                   
"Child Extends Parent means Child IS-A Parent"






Consider another example:
Imagine we now have two specialized subclasses that extend the more generic GameShape class, PlayerPiece and TilePiece:
class GameShape {
public void displayShape() {
System.out.println("displaying shape");
}
// more code
}




class PlayerPiece extends GameShape {
public void movePiece() {
System.out.println("moving game piece");
}
// more code
}
class TilePiece extends GameShape {
public void getAdjacent() {
System.out.println("getting adjacent tiles");
}
// more code
}
Now imagine a test class has a method with a declared argument type of GameShape, that means it can take any kind of GameShape. In other words,any subclass of GameShape can be passed to a method with an argument of type
GameShape. This code


public class TestShapes {
public static void main (String[] args) {
PlayerPiece player = new PlayerPiece();
TilePiece tile = new TilePiece();
doShapes(player);
doShapes(tile);
}
public static void doShapes(GameShape shape) {
shape.displayShape();
}
}


Outputs:
displaying shape
displaying shape



The key point is that the doShapes() method is declared with a GameShape argument but can be passed any subtype (in this example, a subclass) of GameShape.The method can then invoke any method of GameShape, without any concern for the actual runtime class type of the object passed to the method. There are implications, though. The doShapes() method knows only that the objects are a type of GameShape, since that's how the parameter is declared. And using a reference variable declared as type GameShape—regardless of whether the variable is a method parameter, local variable, or instance variable—means that only the methods of GameShape can be invoked on it. The methods you can call on a reference are totally dependent on the declared type of the variable, no matter what
the actual object is, that the reference is referring to. That means you can't use a GameShape variable to call, say, the getAdjacent() method even if the object passed in is of type TilePiece.