Saturday, 28 April 2018

Variable in Java

Variable in Java

Java Variable

What is a variable?
Ans. It is nothing but placeholder of data. It is a memory location. Example int a, b; Here a and b is are variable of data type int.

How many types of variable are there in Java?
It has three types. A local variable, Instance variable, and Class variable.
Local Variable: It is defined within the method and constructor. These variables visibility remain within the method and constructor.
Instance Variables: Define inside a class. It is available for every object of the class.
Class variable: when a variable defines with keyword static inside a class is known as the class variable.
All object of the class shares static variables because of only a single copy of these available in the memory.

State the difference between token and identifier, variable.
Ans.The smallest individual unit of program is called Token. e.g:  Identifiers, Keyword, Literals etc. whereas an identifier is the name given to different parts of a program, it is also known as variables. e.g. variable, functions, classes etc.
Variable: A memory location that stores a value is known as a variable. It is like a box in memory where we keep or store values. E.g. int a;

Explain Instance Variable. Give an example.
Ans. Variables associated with the instance of a class are called instance variables. E.g. 
class ABC
int a,b,c;    // Instance variable
void sum()
a = 20;
b = 30;
c = a + b;

Q. What is final variable?
When a variable defines with the final keyword then its value can be change throughout the whole program.
class Circle{ 
 final int pi=3.14;//final variable cannot be change 
 double a, r;                
 void area(){
  r = 3.5;            
  a = r*r*pi; 
 public static void main(String args[]){ 
 Circle obj=new  Circle(); 
}//end of class 

Q. Can ‘main’ method be declared final?
Yes, the main method can declare as final.
public class Example
    public static final void main(String args[])
        int a=6;

Q. What is static variable?
A static variable is shared by all instances of a class. It is also known as a class variable and it is declared with keyword ‘static’.  Instances (objects) of the same class share a single copy of static variables.
class School
    int rollno; 
    String section;
    String name; 
    static String schoolName ="InspireSkills Edu"; 
    // constructor 
    School(int r, String s, String n){ 
        rollno = r; 
        section = s;
        name = n; 
    void display ()
        System.out.println(rollno + " " + section + "   " + name + " " + schoolName);
    public static void main(String args[])
        School ob1 = new School(1, "A", "Mukesh"); 
        School ob2 = new School(2, "B", "Aryan"); 


More Post
History of java

Wednesday, 28 March 2018

History of java

History of Java

History of Java.
Java is a computer programming language. It is a general-purpose, object-oriented, portable, secure and platform independent language. It was initiated in 1991 by James Gosling, Mike Sheridan, and Patric Naughton. Java was initially called Oak after an Oak tree. Later it named as Java.
·         In the year 1995 Sun Microsystems released Java 1.0 and it was based on WORA(Write once Run Any ware) or we can say platform independent.
·         Arthur van Hoff was the person who re-wrote Java 1.0 compiler strictly adheres to Java 1.0 specification. In December 1998 Java 2 was released by codename Playground and it has major changes. Java 2 name was changed to J2SE.
·         In the year 2000 J2SE 1.3 was released with code name Kestrel and it has bundled with Hotspot JVM, JavaSound, Java Naming, JNDI, and Java platform debugger architecture.
·         In the year 2002 J2SE 1.4 released with code name Merlin, it has included regular expression modeled after PERL.
·         In 2004-2005 J2SE 1.5 released with codename Tiger. In this version, several new features were included like for-each loop, Generics, autoboxing, and var-args.
·         In 2006 Java SE 6 and dropped zero, with code name Mustang. It has bundled with a database manager and facilitates scripting language with JVM.
·         Java SE 7 with codename Dolphin in 2011 with new features added such String in switch-case and it supports dynamic language.
·         In 2014 Java SE 8 was released with lambda expression with code name Spider.
·         The latest released Java SE 9 with Jigsaw as its code name. 

Major release versions of Java, along with their release dates:
JDK 1.0 (January 23, 1996)
JDK 1.1 (February 19, 1997)
J2SE 1.2 (December 8, 1998)
J2SE 1.3 (May 8, 2000)
J2SE 1.4 (February 6, 2002)
J2SE 5.0 (September 30, 2004)
Java SE 6 (December 11, 2006)
Java SE 7 (July 28, 2011)
Java SE 8 (March 18, 2014)
Java SE 9 (September 21, 2017)
There were five major criteria for the creation of this wonderful language which are as follows:
1. Must be an Objected Oriented.
2. Must be a secure and robust language.
3. Must be portable and architectural neutral which mean Java application run anywhere in networks as it generates bytecode which runs's on any OS and networks provided JVM is there.
4. Must be high performance
5. It must be multithreaded
Few features of Java.
General Purpose
Cross Platform
Architecturally neutral
Interpreted Programming Language
Here emp1 and emp2 are reference data types

More Post
Java Data Types


Tuesday, 13 March 2018

Java Data Types

Java data types

Data Types

Data types are used to identify the types of data in a program. It means what kind of data usage is going to put into a memory location.
In Java, there are two categories of data types
  •    Primitive data types(Pre-define)
  •    Reference data types(Non-primitive)

Primitive data types:
It loads automatically into the memory as soon as Java program executes. Primitives single a single value. Primitive data types are predefined by the language and named by a keyword. 
There are Eight primitive data types and it can be divided into four groups.
  1. Integer (byte, short, int, double)
  2. Floating or real number (float, double)
  3. Character (char and it is 16-bit Unicode character)
  4. Boolean (Boolean)

Range of values that can be stored
Default Value
1 byte
−128 to 127
2 bytes
−32768 to 32767
4 bytes
−2,147,483,648 to 2,147,483,647
8 bytes
9,223,372,036,854,775,808 to
4 bytes
3.4e−038 to 3.4e+038
8 bytes
1.7e−308 to 1.7e+038
\u0000 to \uFFFF(Maximum Value-65535)
1 bit
true or false


class JavaDataTypesExample{
     public static void main(String args[])
        byte byteVar = 12;
        short shortVar = 37;
        int intVar =80;
        long longVar =898034892149L;
        float floatVar = 20.563423424f;
        double doubleVar = 20.12323423423468326;
        boolean booleanVar = true;
        char charVar ='A';
        System.out.println("Value Of byte Variable is       " + byteVar);
        System.out.println("Value Of short Variable is      " + shortVar);
        System.out.println("Value Of int Variable is        " + intVar);
        System.out.println("Value Of long Variable is       " + longVar);
        System.out.println("Value Of float Variable is      " + floatVar);
        System.out.println("Value Of double Variable is     " + doubleVar);
        System.out.println("Value Of boolean Variable is    " + booleanVar);
        System.out.println("Value Of char Variable is       " + charVar);

Value Of byte Variable is       12
Value Of short Variable is      37
Value Of int Variable is        80
Value Of long Variable is       898034892149
Value Of float Variable is      20.563423
Value Of double Variable is     20.123234234234683
Value Of boolean Variable is    true
Value Of char Variable is       A

Reference Data types:
Non-Primitive or Reference data types are formed with the help of primitive data types. It is created by the programmer. It stores the memory address of an object.  The default value of any reference variable is null. Example classes, interface, Arrays, String.
class Employee
   String name;
    String aadhar;
    String emailAddress;
    int yearOfBirth;
class EmpDetail
public static void main(String[] args) {
        Employee emp1 = new Employee(); // Reference Data type
        emp = "Habib";
        emp 1.aadhar = "4525-4545-4345-3423";
        emp 1.emailAddress = "";

        Employee emp2 = new Employee();// Reference Data type
        emp = "Sachin";
        emp 2. aadhar = "4563-7384-9031";
        emp 2.yearOfBirth = 1974;

        System.out.println("Name: " + emp;
        System.out.println("Aadhar: " + emp 1.aadhar);
        System.out.println("Email Address: " + emp 1.emailAddress);
        System.out.println("Year Of Birth: " + emp 1.yearOfBirth);

        System.out.println("Name: " + emp;
        System.out.println("Aadhar: " + emp 2.aadhar);
        System.out.println("Email Address: " + emp2.emailAddress);
        System.out.println("Year Of Birth: " + emp2.yearOfBirth);


Here emp1 and emp2 are reference data types

Friday, 2 February 2018

Practice Java by Building Projects

If your goal is to GET HIRED, then you need to PASS THE INTERVIEW!
The BEST way to prepare for a technical interview is to get practice building applications and applying core principles of object-oriented design. I've designed this course to accomplish that objective.
Many people fail interviews because:
·         They don't grasp object-oriented programming concepts
·         They can't apply object-oriented design in an actual program
·         They haven't practiced developing their applications by hand
·         They haven't debugged their code and overcome challenges
This course is designed for someone who simply wants to get better at understanding and applying Java design and object-oriented programming. It is perhaps the most effective thing you can do to prepare for your job interview. Forget about flashcards, forget about quizzes. Start practicing!
In this Practical Java course, you will build realistic projects from scratch. We will approach each program analytically and outline our approach to implement the solution. Then, piece by piece we will write the code to create a fully functioning application.
·         Understand client scenarios and requirements
·         Approach each problem analytically
·         Write our solution outline
·         Implement code step-by-step
·         Apply core principals of object-oriented design
Everyone hoping to start out in Java needs to practice! It's not enough to learn and watch, but you must try yourself! To enroll in this course and get typing!
Note: this course was built for someone who has some working knowledge and familiarity with Java or application design. Please learn some bit of Java programming and its concepts then you can build these projects. Good Luck.
Who is the target audience?
Current students or recent graduates
 Anyone looking to practice Java
Someone preparing for a Java interview
Someone starting a new Java project
 Anyone wanting a refresher on object-oriented programming or application architecture
Familiar with Java development environment
Knowledge of object-oriented programming concepts recommended
Register in and then click on Get the Code below...... enjoy the Java project and advance in your career. Good Luck.

 Get the Code

Saturday, 16 September 2017

Generation of Computer

Computer Of Generation

First Generation of Computers (1942-1955)

The period of the first generation was 1942-1956.This generation computer used vacuum tubes as the basic components for memory and circuitry for Central Processing Unit. The two notable machines of this era were the UNIVAC and ENIAC machines – the UNIVAC is the first every commercial computer which was purchased in 1951 by a business – the US Census Bureau. The computers in this generation used machine code as a programming language. These computers were limited to solving one problem at a time. Input was based on punched cards and paper tape. 
  • Faster than its predecessor (Before First Generation).
  • The vacuum tube was used.
  • These computers could calculate data in millisecond (10-3 Second).

  • Computer huge in size.
  • Unreliable
  • Very costly.
  • Consumed a large amount of heat.
  • Air condition required.
  • Not portable because of its size.
  • Maintenance of computer was required.

Second Generation Computers (1956-1965)

In this generation, Transistor replaced Vacuum tube. The period of the second generation was 1956-1965. By using Transistor computer was becoming more reliable, less expensive, consume less power than first generation computer. In this generation assembly language and high-level programming languages like FORTRAN, COBOL was used. The computers used batch processing. The examples of second generation computers are IBM 1620, IBM 7094 seriesIBM 1400 series and CDC 164, UNIVAC 1108 etc.
  • Faster than the First Generation.
  • Transistor used which was superior to Vacuum tube.
  • More reliable
  • Cheaper than the first generation.
  • Size reduced.
  • Magnetic tape was used which was more reliable than the Punchcard.
  • Less heat generates.

  • Air condition still required.
  • Still big.
  • Too much Costly.

Third Generation Computers (1966-1975)

In this generation, IC (Integrated Circuit) was used. It was developed by Jack Kilby. It was much faster than the second generation computer. These generation computers were used keyboards and monitors and also used the operating system. These generation computers were smaller in size, reliable and efficient. From this generation onward high-level languages were used such as FORTRAN-II TO IV, COBOL, PASCAL PL/1, BASIC, ALGOL-68 etc.

  • Faster and reliable than the Second generation.
  • Used less power
  • Smaller in size
  • Commercially available
  • Large storage capacity

  •  Air condition still required
  • Still costlier

Fourth Generation Computers (1975-Present)

The computer we see today is fourth generation computer. The fourth generation computers were the extension of third-generation technology. The fourth generation computers emerged with the development of the VLSI (Very Large Scale Integration).The microprocessor is used in fourth generation computer. This generation computer is faster, reliable, cost-effective.

  • The computer becomes affordable to the mass.
  • The speed, accuracy, and reliability of the computers were improved.
  •  Many high-level languages were developed in the fourth generation such as COBOL, FORTRAN, BASIC, PASCAL, C, C++, Java languages.
  • No AC required.
  • Less power consumption.

  • ·         Sophisticated and complex technologies required.

Fifth Generation Computers (Artificial Intelligent)

The fifth generation computer still in development. This generation computer becomes equipped with artificial intelligence which means a computer can think of its own by using some advanced language. Computers can understand spoken words & imitate human reasoning. It Can respond to its surroundings using different types of sensors.