Posts

#Constructor

             Constructor  Constructor means name of the classes same but Parameter will be different. Object does not to create of constructor  Program: class First  { void Display() { System.out.println("Hello world"); } public static void main (String[] args) { First f1=new First(); f1.Display(); } } Output:- Hello World First = Default Constructor,implicit constructor Types Of Constructor Default Parameterized Copy Explicit Constructor:- Explicit Constructor are those constructor in which are declare or provide by user . These constructor are visible or declare outside of class . Implicit Constructor:- implicit constructor are invisible.

#Coding || Java || Inheritance

Image
  Java Inheritance  The mechanism of deriving a new class from an old one is called inheritance ⚫ Allows subclasses to inherit all the variables  and methods of their parent classes ⚫ Old Class-> Base Class->Super class-> Parent Class ⚫ New Class-> Subclass->Derived Class-> child clas. Types of Inheritance                 Defining a Subclass in Java Inheritance is declared using the "extends" keyword. If inheritance is not defined, the class extends a class called Object          Class subclassname extends superclassname    {       variables declaration       methods declaration } Inheritance Hierarchy Each  Java class has one (and only one) superclass. Inheritance creates a class hierarchy Classes higheer in the hierarchy are more general and more abstract Classes lower in the hierarchy are more specific . package com.demo; public...

#Coding || Multithreading || Thread

Multithreading Programming Those who are familiar with the modern operating systems such as Windows 95 and Windows XP may recognize that they can execute several programs simultaneously.This ability is known as   M ultitasking .  This term is also known as Multithreading. A programming concept where a program 

Method Overloading in java

Image
METHOD OVERLOADING  Method overloading means more than one methods and different arguments(Parameters). Static method is data members. Static method is mandatory. Without main method not executing the program. Main method is not mandetory for compilation. Program :- class Demo  { public static void main(String [] a) {      Demo d1=new Demo();      //d1.main();      //Demo.main();  //main(); System.out.println("Hello"); main(10); } public static void main() { System.out.println("main method"); } public static void main(int a) { System.out.println("another method"); } } Output:- main method Hello another method

# Java || Identifiers # Literals # Separators # Operators

IDENTIFIER UES IN JAVA Identifiers refers to the names of variables, arrays, class,methods etc. created by the user. The rules for identifier are : 1. An identifier may consists of letters(A-Z,a-z), digits(0-9), underscore(_) and dollar sign ($). 2. Blank spaces(  ) are not allowed. 3. The first character must be a letter(A-Z,a-z), underscore(_) or dollar sign($). 4. Keywords or Reserved words are not allowed here. Both upper case(A-Z) and lower case(a-z) letters are allowed and are considered to distinguishable. e.g. the identifier SUM is not same as sum or Sum The following are valid identifiers area                                               Average  sum                                              John  table1      ...
Image
   Console Input/Output in Java Input/Output  in Java can be done using the keyboard and screen, using files some combination of these methods.  * Input typed at the keyboard and output displa on the screen are often referred to as console     input/output. * Interactive input/output using the keyboard and screen is the default way of do input/output in Java. Note: An Object is always needed to perform an input/output operation in Java .   Standard Output Displaying screen output in Java is done using the System.out object. You do not need to create the System.out object. It is always available for you in a Java program There are three methods that can be used to display output (a) print() Method The print() method is often used to display a prompt or a portion of a line. I does not move the cursor to the beginning of a new line automatically. E.g. class demo {    public static void main(String args[]) //Use of print() method { System.ou...

# How to write java program #Structure || Java Program

Image
  Structure of Java Program A java program must contain a main method as its starting point. (a) Documentation section  This section contain the comments giving the name of program, author's name  and other details9 (b) Package Statement  This statement declares a package name and informs the compiler that the classes defined here belong to this package. (c) Import Statement This statement is similar to the #include statement in C++ Example: import java.lang. Math; This statement instructs the interpreter to load the Math class from the package lang . Note :-  Math class contain mathematical methods like sqrt etc (d) Interface Statements An interface statement is used only when we wish to implement the multiple inheritance feature in the program. (e) Class Definitions A Java program may contain several class definitions. Define all classes . (f)  Main Method Class Every Java program requires a main method as its starting point. This class  the esse...