6 Aug 2016

Primitive Data Types in Java

Primitive data types are predefined by the java language and named by a keyword. There are totally eight Primitive Data Types in Java. Based on the data type of a variable, the operating system allocates memory and decides what can be stored in the reserved memory.
Therefore, by assigning different data types to variables, we can store various data types in these variables.
The following table gives the detail information about Primitive Data Types:

Primitive Data Types (Table)

DataType Default Value Size Type
byte 0 1 byte Integral Value
short 0 2 byte Integral Value
int 0 4 byte Integral Value
long 0L 8 byte Integral Value
float 0.0f 4 byte Floating Point
double 0.0d 8 byte Floating Point
char '\u0000' 2 byte Character
boolean false 1 bit Boolean
Note: \u0000 means 0 in UNICODE (Universal International Standard Character Encoding)
Read More
If u like the post you can follow us

If you have any suggestions for us or if you are interested to write or advertise here you can mail us at viveksingh12126@gmail.com

31 Jul 2016

Java Program using Two different Classes in Two Different File

TestEmployee1.java

public class TestEmployee1 {
public static void main(String[] args) {
Employee1 alex = new Employee1(); //creating 3 objects "alex, linda and john" of the class Employee1
Employee1 linda= new Employee1();
Employee1 john= new Employee1();

alex.salary = 10000; // assigning salary to the object "alex"
alex.bonus = 2000;

linda.salary = 12000;
linda.bonus =1000;

john.salary = 8000;
john.bonus = 3000;

alex.calculateTotalPay(); //here calculateTotalPay() is a method defined in Employee1 class
linda.calculateTotalPay(); // we r invoking that method
john.calculateTotalPay(); //will print total pay of john

}
}

Employee1.java

public class Employee1 {
double salary;
double bonus;

void calculateTotalPay() {
double totalPay = salary + bonus;
System.out.println("Total Pay = " +totalPay); //concatenation used to get totalPay
}
}

Output:
C:\Program Files\Java\jdk1.8.065\bin>javac Employee1.java
C:\Program Files\Java\jdk1.8.065\bin>javac TestEmployee1.java
C:\Program Files\Java\jdk1.8.065\bin>java TestEmployee1

Total Pay = 12000.0
Total Pay = 13000.0
Total Pay = 11000.0
Read More

Simple Java Programs with Output

This post contains a list of basic java programs for beginners. These programs will provide you a good understanding of the basics that how java programs work. All coding written below is well tested. Before you start executing these codes you must need these things to be done first:
  • install the JDK ( Java Development Kit )
  • set path of the jdk/bin directory
You also need to remember that in Java the filename should be same as your class name.

1. Even Or Odd Numbers Checking (with user input)

import java.util.Scanner;

class OddOrEven
{
   public static void main(String args[])
   {
      int x;
      System.out.println("Enter an integer ");
      Scanner in = new Scanner(System.in); //To ask input from user
      x = in.nextInt();

// remainder after dividing x by2
      if ( x % 2 == 0 )
         System.out.println("You entered " + "'" + x + "'" + " which is an even number.");
      else
         System.out.println("You entered " + "'" + x + "'" + " which is an odd number.");
   }

}
Outputs:
Enter an integer 2
You entered 2 which is an even number

Enter an integer 2
You entered 2 which is an even number


2. Printing Week Days (Using For Loop)

import java.text.DateFormatSymbols;
public class PrintWeekDays {
public static void main(String[] args) {
    String[] weekdays = new DateFormatSymbols().getWeekdays();
// to Get day names
    for(String s: weekdays){
      System.out.println(s);
} } }

Output:
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday

3. List Of Even Numbers (1 to any (both inclusive))

/*
        find and list even numbers between 1 and any given number.
*/
public class ListEvenNumbers {
        public static void main(String[] args) {
               
                //define limit
                int limit = 10;
               
                System.out.println("Printing Even numbers between 1 and " + limit);
               
                for(int i=1; i <= limit; i++){
                       
                        // if the number is divisible by 2 then it is even
                        if( i % 2 == 0){
                                System.out.print(i + " ");
                        }
                }
        }
}

Output:
Printing Even Numbers between 1 and 10
2 4 6 8 10

4. Multiplication Table (By User Input)

import java.util.Scanner;
class MultiplicationTable
{
   public static void main(String args[])
   {
      int n, c;
      System.out.println("Enter an integer to print it's multiplication table:");
      Scanner in = new Scanner(System.in);
      n = in.nextInt();
      System.out.println("Multiplication table of "+n+" is :-");
      for ( c = 1 ; c <= 10 ; c++ )
         System.out.println(n+"*"+c+" = "+(n*c));
   }
}

Output:
Enter an integer to print it's multiplication table:
2
Multiplication table of  2 is :-
2*1 = 2
2*2 = 4
2*3 = 6
2*4 = 8
2*5 = 10
2*6 = 12
2*7 = 14
2*8 = 16
2*9 = 18
2*10 = 20


5. Printing Text ( Hello World )

public class MyFirstJavaProgram {

   /* This is my first java program.  
    * This will print 'Hello World' as the output
    */
    public static void main(String []args) {
       System.out.println("Hello World"); // prints Hello World
    }

Output:
Hello World

6. Rectangle Measurement (Squares Included)

import java.util.Scanner;
class RectDemo
{
   public static void main(String args[])
   {
      Scanner sc = new Scanner(System.in);//This is necessary for inputs
    
  System.out.print("Enter the length of Rectangle: ");
  double length = sc.nextDouble();  //Takes the user input as length

  System.out.print("Enter the breadth of Rectangle: ");
      double breadth = sc.nextDouble();

      if(length==breadth){
double area = length * breadth;
        System.out.println("The area of Square is: " + area);

        double perimeter= 2 * (length + breadth);
        System.out.println( "The perimeter of the Square is:"+perimeter) ;
    }else{
        double area = length * breadth;
        System.out.println("The area of Rectangle is: " + area);

        double perimeter= 2 * (length + breadth);
        System.out.println( "The perimeter of the rectangle is:"+perimeter) ;
}
   }
}

Output:
Enter the length of Rectangle: 2
Enter the breadth of Rectangle: 3
The area of Rectangle is: 6.0
The perimeter of Rectangle is:10.0

Read More

16 Dec 2015

Non‐Recognised Boards/Universities In India By NIOS

Here is a list of school/university boards which are not recognised by NIOS (National Institute of Open Schooling). Since NIOS is a government board and also one of the world's biggest open schooling board. So one should be remembring this while going for admissions in schools. Its always recommended to verify the board before taking admissions. And if you want to be on a safer side then always go for national boards like CBSE, ICSE, etc.

Sr. No. Board/University Name Address
1 Central Board of Higher Education Aspati Bhawan, Uttam Nagar, New Delhi.
2 All India Board of Secondary Education Gazipur
3 Central Board of Higher Education East Patel Nagar, New Delhi.
4 Board of Adult Education and Training Brahmpuri, Nagal Rai, New Delhi.
5 Gurukul Vishwavidyalaya Vrindavan
6 Akhil Bhartiya Shiksha Sansthan New Delhi.
7 ACN International University Raipur
8 Doon International University Raipur
9 Board of Higher Secondary Education Delhi
10 Indian Council of Secondary Education India
11 All India Board for Education Training Delhi
12 All India Board for Secondary Education Delhi
13 Board of Adult Education & Tarining Delhi
14 Central Board of Higher Education Delhi
15 Jamia Urdu Aligarh
16 Gurukul Vishvavidyalaya Vrindaban Mathura
17 Council of Secondary Education Mohali
18 Mahashakti Sanskrit Vidyapeeth Delhi
19 Council for the Indian Certificate Examination Delhi
20 Bhartiya Shiksha Parishad Lucknow
21 Board of Secondary Sanskrit Education Lucknow
22 Hindi Sahitya Sammelan Allahabad
23 Mumbai Hindi Vidyapeeth Mumbai
24 The Central Board of Higher Education New delhi
25 Dr. Ramgopalacharya Sanskrit Mahavidalaya Etah, U.P.
26 Board of Secondary Education Madhya Bharat Gwalior
27 Council of Secondary Education Board Mohali
28 Mahatma Gandhi Secondary and Senior Secondary Education Board Delhi
29 Board of Secondary and Higher Secondary Open Education West Bengal
30 Board of Youth Education India
31 The Council of Basic and Technical Education Ludhiana
32 Shiksha Parishad Madhyamic Gwalior
33 Central Board of Education Ajmer
34 Council of Higher Secondary Education Delhi
35 Board of Secondary Education Madhya Bharat Gwalior
36 Delhi Board of Senior Secondary Education Delhi
37 Board of Technical and Secondary Education Delhi
38 Board of Youth Education in India
39 Mahatma Gandhi Secondary and Senior Secondary Education Board Delhi
40 Council of Higher Secondary Education Delhi
41 Indian Council Open School Certificate Examination Maharashtra
42 Mahakoshal Board of Secondary Education Jabalpur
43 National Board of Higher Secondary Education Delhi
44 Board of Higher Secondary Open Education Delhi
45 Board of School and Technical Education Chhatisgarh
46 Board of Senior Secondary Education
47 Delhi Board of Senior Secondary Education

Source: nios
Read More

27 Nov 2015

Chemical Reactions (Ch 1)

Important Terms
Important Questions solved (CBSE)

Important Terms

  • Chemical reaction
Reactants reacts to form products

  • Chemical equation
A chemical equation represents a chemical reaction with their respective chemical formulas.

  • Skeletal Chemical Equation
A simple chemical equation which represents symbols of compounds or elements of reactants and products taking part in a chemical reaction

  • Balanced Chemical Equation
A Balanced Chemical Equation is the one in which the total number of atoms of each elements of the reactants is equal to the total number of atoms of reacted products

  • Representation of symbols of various physical states
Solids  (s)
Liquid  (l)
Gases  (g)
Aqueous (aq) {NOTE: Aqueous is not same as liquid}

Writing Chemical Equations 

1. In a chemical reaction, the reactants are written on the left hand side and the products on the right hand side of the equation.

2. An arrow (→) pointing towards the products is inserted between the reactants and the products. It also represents the direction of the reaction.

3. A single arrow (→) indicates the direction in which the reaction proceeds.

4. A double arrow ( ) indicates a reversible reaction, i.e. the products recombine to form the reactants.

5. A plus sign (+) is inserted between two or more reactants or products formed.

6. If reactions are carried out under specific conditions of temperature, pressure, catalyst etc., then these conditions are mentioned on the arrow.

7. The chemical equation can be made more informative by mentioning the physical states of the reactants and products.

8. If gas is liberated as a product then it is represented by an arrow pointing upwards (↑). If the product formed is in the form of a precipitate, it is represented by an arrow pointing downwards (↓). Balancing the Chemical Equations

9. In a balanced chemical equation, the total number of atoms of each element of the reactants on the left hand side of the equation is equal to the number of atoms of the products formed on the right hand side of the equation.

10. The total mass of the reactants is equal to the total mass of the products or the number of atoms of each element before the reaction and after the reaction is equal.

Types Of  Reaction

Combination Reaction
When two or more substances combine to form a single product, the reaction is known as a combination
reaction.
For example:
In the laboratory, iron sulphide is prepared by mixing iron and sulphur.
Fe(s) + S(s)  FeS(s)
⇒ Endothermic Reaction: The reactions accompanied by the absorption of heat are called
endothermic reactions.
⇒ Exothermic Reaction:
The reactions accompanied by the evolution of heat are called endothermic
reactions.

Decomposition Reaction
A chemical reaction in which a single compound splits into two or more simple substances is called a
decomposition reaction.
For example:
When mercuric oxide is heated in a crucible, the orange-red powder begins to darken and a silver mirror
begins to deposit on the cooler parts of the crucible.
2HgO(s)   →    2Hg(s) + O2 ↑
Mercuric oxide Mercury Oxygen

Displacement Reaction
Reactions in which the more reactive element displaces the less reactive element from its compound are called displacement reactions.
For example:
Zinc displaces copper in copper sulphate to form zinc sulphate.
Zn(s) + CuSO4 (aq) → ZnSO4 (aq) + Cu(s)
Zinc Copper sulphate  Zinc sulphate Copper

Double Displacement Reaction
Reactions in which ions of the reactants exchange places to form two new compounds, are called double displacement reactions.
For example:
Sodium hydroxide reacts with hydrochloric acid to form sodium chloride and water.
NaOH(aq) + HCl(aq) → NaCl(aq) + H2O(l)

Redox Reaction
The chemical reaction in which oxidation and reduction takes place simultaneously is known as a redox reaction.

Oxidation Reactions
Reactions which involve the addition of oxygen or the removal of hydrogen are called oxidation reactions.
For example:
C(s) + 2H2 (g)  CH4 (g)

Reduction Reactions
Chemical reactions in which the reactants gain hydrogen are reduction reactions.
For example:
 Fe2O3 + 3CO 2Fe + 3CO2↑
Ferric oxide Carbon monoxide Iron Carbon dioxide


Corrosion
The slow process of decay and destruction of metals due to the action of air, moisture or acids is called corrosion.
For example:
Iron combines with oxygen present in the air, in the presence of water, to form a red-brown flaky
substance called rust. This process is commonly called the rusting of iron.
The chemical formula of rust is Fe2O3. x H2O.


Prevention of Corrosion

Corrosion damages buildings, bridges, ships, automobiles and other articles made of iron. Hence,
prevention of corrosion is necessary. This will not only save money but can also prevent the
occurrence of accidents.

It can be prevented by processes like galvanising and electroplating with other metals.

Rancidity
Oils and fats react with oxygen and get oxidised or turn rancid. This process is called rancidity.
Rancidity can be prevented by keeping food in air tight containers or by using antioxidants.
Antioxidants are used to prevent oxidation of food containing fats and oils.
Storage of food in air tight containers also decelerates oxidation.


Important Questions (CBSE)

Important questions will be published here soon.
Read More