• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » Java » Java

Explain Java Thread Model

By Dinesh Thakur

The Java language and its run-time system was designed keeping in mind about multithreading. The run-time system depend upon multithreading. Java provides asynchronous thread environment, this helps to increase the utilization of CPU.

Multithreading is best in all cases in contrast with single-thread model. Single-thread system uses an approach of event loop with polling. According to this approach a single thread in the system runs in an infinite loop. Polling the mechanism, that selects a single event from the event queue to choose what to do next. As the event is selected, then event loop forwards the control to the corresponding required event handler. Nothing else can be happened, until the event handler returns. Because of this CPU time is wasted. Here, only one part of the complete program is dominating the whole system, and preventing the system to execute or start any other process. In single-thread model one thread blocks all other threads until its execution completes. On other waiting or idle thread can start and acquire the resource which is not in use by the current thread. This causes the wastage of resources.

Java’s multithreading provides benefit in this area by eliminating the loop and polling mechanism, one thread can be paused without stopping the other parts of the program. If any thread is paused or blocked, still other threads continue to run.

As the process has several states, similarly a thread exists in several states. A thread can be in the following states:

Ready to run (New): First time as soon as it gets CPU time.

Running: Under execution.

Suspended: Temporarily not active or under execution.

Blocked: Waiting for resources.

Resumed: Suspended thread resumed, and start from where it left off.

Terminated: Halts the execution immediately and never resumes.

            Java Thread Model

Java thread model can be defined in the following three sections:

Thread Priorities

Each thread has its own priority in Java. Thread priority is an absolute integer value. Thread priority decides only when a thread switches from one running thread to next, called context switching. Priority does increase the running time of the thread or gives faster execution.

Synchronization

Java supports an asynchronous multithreading, any number of thread can run simultaneously without disturbing other to access individual resources at different instant of time or shareable resources. But some time it may be possible that shareable resources are used by at least two threads or more than two threads, one has to write at the same time, or one has to write and other thread is in the middle of reading it. For such type of situations and circumstances Java implements synchronization model called monitor. The monitor was first defined by C.A.R. Hoare. You can consider the monitor as a box, in which only one thread can reside. As a thread enter in monitor, all other threads have to wait until that thread exits from the monitor. In such a way, a monitor protects the shareable resources used by it being manipulated by other waiting threads at the same instant of time. Java provides a simple methodology to implement

synchronization.

Messaging

A program is a collection of more than one thread. Threads can communicate with each other. Java supports messaging between the threads with lost-cost. It provides methods to all objects for inter-thread communication. As a thread exits from synchronization state, it notifies all the waiting threads.

Adding Classes From A Package to Your Program

By Dinesh Thakur

The packages are used for categorization of the same type of classes and interface in a single unit. There is no core or in-built classes that belong to unnamed default package. To use any classes or interface in other class, we need to use it with their fully qualified type name. But some time, we’ve the need to use all or not all the classes or interface of a package then it’s a tedious job to use in such a way discussed. Java supports imports statement to bring entire package, or certain classes into visibility. It provides flexibility to the programmer to save a lot of time just by importing the classes in his/her program, instead of rewriting them.

In a Java source file, import statements occur immediately following the package statement (if it exists) and must be before of any class definitions. This is the general form is as follows:

 

import pkg1 (.pkg2). [classname|*l;

For example

import java.util.Vector;

import java.io.*;

import java.awt.*;

import java.awt.event.*;

 

The star (*) increases the compilation time, if the package size is very large. A good programming methodology says that give the fully qualified type name explicitly, i.e. import only those classes or interface that you want to use instead of importing whole packages. Yet the start will not increase the overhead on run-time performance of code or size of classes.

 

Example:

//Student.java

package student;

class Student

{

private int rollno;

private String name;

private String address;

public Student(int rno, String sname, String sadd}

{

 

rollno = rno;

name = sname;

address = sadd;

}

public void show()

{

System.out.println(“Roll No :: ” + rollno);

System.out.println(“Name :: ” + name);

System.out.println(“Address :: ” + address);

}

}

// Test.java

 

package student;

class Test extends Student

 

{

protected int marksSubjecti;

protected int marksSubject2;

protected int marksSubject3;

protected int marksSubject4;

public Test(int rno, String sname, String sadd,int mi, int m2, int m3, int m4)

{

super(rno,sname,sadd);

marksSubjecti = mi;

marksSubject2 = m2;

marksSubject3 = m3;

marksSubject4 = m4;

}

public void show()

{

super.show();

System.out.println(“Marks of Subject1 :: ” + marksSubject1);

System.out.println(“Marks of Subject2 :: ” + marksSubject2);

System.out.println(“Marks of Subject3 :: ” + marksSubject3);

System.out.println(“Marks of Subject4 :: ” + marksSubject4);

}

}

 

//Result.java

 

package student;

public class Result ex..tends Test

{

private int totalMarks;

private float percentage;

private char grade;

public Result(int rno, String sname, String sadd,int mi, int m2, int m3, int m4)

{

super(rno,sname,sadd,ml,m2,m3,m4);

 

totalMarks = marksSubject1 + marksSubject2 + marksSubject3 + marksSubject4;

percentage = (totalMarks*100.00F/600.00F);

if (percentage >=50.00F)

grade=’D’;

else

if(percentage >=55.00F && percentage<=60.00F)

grade = ‘C’;

else

if (percentage >=6l.00F && percentage<=70.00F)

grade = ‘B’;

else

if(percentage >=7l.00F && percentage<=75.00F)

grade = ‘A’;

else

if (percentage >=76.00F && percentage<=85.00F)

grade = ‘H’;

else

grade = ‘S’;

}

public void show()

{

super.show();

System.out.println(“Total Marks :: ” + totalMarks);

System.out.println(“Percentage :: ” + percentage);

System.out.println(“Grade :: ” + grade);

}

}

//ImportPackageDemo.java

import student.Result;

public class ImportPackageDemo

{

public static void main(String ar[])

{

Result ob = new Result (1001, “Alice”, “New York”,135,130,132,138);

ob.show ();

}

}

In the source file ImportPackageDemo, import student. Result is the first statement; it will import the class Result from the student package.

Access Protection in Packages

By Dinesh Thakur

Access modifiers define the scope of the class and its members (data and methods). For example, private members are accessible within the same class members (methods). Java provides many levels of security that provides the visibility of members (variables and methods) within the classes, subclasses, and packages. [Read more…] about Access Protection in Packages

What is Packages in Java ? with Example

By Dinesh Thakur

One of the critical aims of Java and other object-oriented programming languages is that reusable classes should be created and made available to programmers so that the same code is not written repeatedly by different people. We reused the classes within a program by extending the classes and implementing the interfaces. Moreover, most of the classes that we created so far did not interact much with the outside world as they were almost self-contained, except that some of them referred to Java classes such as String from java.lang package and Scanner from java.util.lang package. However, while designing most of the real world applications, the developers write code in the form of Java classes, which eventually needs to be brought together to work as a single application.

When more than one programmer writes a more extensive application, several problems may arise such as
• There may be naming conflicts, i.e., the same class name may be given by different programmers while designing classes.
• Difficult to find the classes that are related in some way but scattered in different files/ folders.
• Cannot restrict access to your classes.
These problems can be solved using the concept of packages.

Packages In Java

A package is a collection of related classes that provides a convenient mechanism for managing a broad set of classes and prevents class name conflicts. The classes in the package are grouped by purpose or by an application. It enables you to keep your classes separated from the classes in the Java API, allow you to reuse your classes in other applications and even let you distribute your classes to others.
Java platform includes several packages that group classes according to their functionality. For example, Input/Output classes are in java. io package, utility classes in java.util package, applet classes in java.applet and so on. Each standard package name begins with java, javax, etc.

In Java, every class contained in a package including those that you have defined so far in the various programming examples. However, you never referred to any package explicitly while creating your classes. It is because you have been implicitly using the default package to hold your classes, and this does not have a name. Any class in a single directory on your hard disk that does not specify a package name are part of the default package. Using the unnamed package is acceptable for small projects, but in most cases, it is better to organize classes into named packages to provide better encapsulation.

Packages can not only contain classes but may also contain other packages. Each subpackage usually represents a smaller more specific group of classes. Packages arranged hierarchically. Each subpackage is separated from a package above it by a period (.) which indicates this subpackage is one level below the package defined above it. For example, java.util.Scanner specifies that Scanner is a class in the package util and util is a package in the package java.

Scanner is a class in the package

The package java.util indicates that the package java is at the first level. The subpackage util which is separated by a dot from is java one level below it. Moving each level down, we get more specific information about classes. So the java.util package contains utility classes.

The JDK relies on the computer hierarchical file system to manage packages. It organizes its vast collection of classes into a tree-like hierarchy of packages within packages which is equivalent to directories within directories. In other words, Java expects one to one mapping of the package name and file system directory structure. For example, in the package java. uti!, each part separated by a period (.), i.e., java and util, each correspond to a directory. The first directory is the java directory and within this directory is the subdirectory util. So the path corresponding to this package is java\util in the windows system.

Creating a Java Package

Creating a Java package is quite simple. You just need to follow the following steps.

1. Choose a package name: Naming a package is a crucial aspect of creating a package. The package name must be unique to prevent the problem of name conflicts. By convention, package names begin with a lowercase letter to distinguish them from the class names.
We shall shortly be creating a package named shapes3d which shall contain classes relating to three-dimensional shapes such as Sphere.java, Cuboid.java.

Often the companies that are involved in software development use their unique domain name to name their package — the elements in the domain name written in the reverse order to make it easier to read. For example, If the domain name of the company is ecomputernotes. com then it should place all their code into packages that have names beginning with com.ecomputernotes.

2. Pick up a base or root directory: After choosing the package name, the next step is to choose a base directory for your source tree. The base directory is the directory that contains the directories for your various packages. In our example, we use c: \javaprog as a base directory.

3. Make a subdirectory from the base directory that matches your package name: Since our package name is shapes3d so create a subdirectory named shapes3d in the base directory c:\javaprog.

4. Declaring package members: In this step, add a package declaration to the source file of each class that is part of the package. Placing a package declaration in the java source file indicates that the class declared in the file is the part of the specified package.
The package declaration must contain the keyword package followed by an identifier and a semicolon. For example, to create a package named sphere3d, use the following package declaration
package sphere3d;
The package declaration must be the first non-comment, a non-blank statement in the source file. There can be only one package statement per source file, so all classes in the source file must be in the same package.

In order to put the Sphere class in the shapes3d package, create the Sphere.java file as shown

// sphere class in shapes3d package
package shapes3d;
public class Sphere {
    double radius;
         public Sphere(double r){ radius = r;}
         public double volume(){
            return((4.0*Math.PI * radius * radius * radius)/3.0);
         }
         public double surfaceArea(){
           return(4.0*Math.PI * radius * radius);
         }
}

The Sphere class is declared public. If it is not declared public, it can only use by other classes in the same package. If you want to put several classes into the package, you have to create a separate source file for each of them because a file can have only one public class.

You can also create a hierarchy of packages. For this, you need to separate each package name from the one above it by use of a period (.). Its syntax is
package pack1.pack2 …. packN;
For example:
Package A.B; must be stored in base directory/A/B.
5. Place your source file into the package subdirectory: Once Sphere.java file has created; it is necessary to save it into the package subdirectory shapes3d. So the file Sphere.java the path
C:\javaprog\shapes3d\Sphere.java
6. Compile your source files – The next step is to compile the classes in the package as usual. So in our case, the class Sphere. java compiled using the following command.
C:\javaprog\shapes3d>javac Sphere.java
Similarly, follow the same steps for creating the Cuboid. java file and compile it.

//Cuboid class in shapes3d package
package shapes3d;
public class Cuboid {
        double length ,
width , height;
        public Cuboid(double l , double w , double h) {
            length = l; width = w; height = h;
        }
      public double volume() {
           return(length * width * height);
      }
      public double surfaceArea() {
         return(2.0 * (length * width + width * height + height * length));
      }
}

Now the file organization will look like,

packages file organization

COMPILING WITH -d(directory) FLAG

So far in our discussion, the source file and the class file were stored in the same directory. But quite often while working with projects, the source files and the class files are stored separately. In order to explain this, let us consider an example of the directory structure as shown in Fig.

From the Fig., we come to know that the source file Sphere.Java is stored in the directory path

C:\javaprog\source\shapes3d
Now if we want to store the class file Sphere.class that obtained on compiling the source file in the similar directory structure but under the classes directory then for this, you need to compile the file with -d flag. Compiling with -d flag tells the compiler not just to put your classes into the correct directory structure but also create the directories if they do not exist. The advantage of this approach is that we do not have to create the directories under the classes directory manually.

The command that helps to create the class file under the classes directory is as follows.

C:\javaprog>javac -d classes source\shapes3d\Sphere.java
After executing the above command in the classes directory, the directory shapes3d will be created which will contain Sphere.class file.

What is Interface? Explain Implementation of Interfaces.

By Dinesh Thakur

An interface is a way of describing what classes should do, without specifying how they should do it. A class can implement more than one interface. In Java, an interface is not a class but a set of requirements for the class that we want to conform to the interface. All the methods of an interface are by default public. So, it is not required to use the keyword public when declaring a method in an interface. Interfaces can also have more than one method. Interfaces can also define constants but do not implement methods. An interface is defined like a class. Its general form is:

 

access_specifier interface InterfaceName

(

Return-type Method-l(Parameters);

Return-type Method-2(Parameters);

Type variable-l=value;

Type variable-2=value;

Return-type Method-N(Parameters);

Type variable-N=value;

 

To make a class implement an interface, we must declare that the class intends to implement the given interface and we need to supply definitions for all methods using the implements keyword.

When an interface has been defined, any of the classes can implement that interface. The general form of the class that includes an implements clause is:

 

class classname extends superclass implements interface

{

//class body

}

 

If we say that the Employee class implements the Comparable interface, this can be written as:

 

                   class Employee implements Comparable

 

Interface is a fully abstract class. Using the keyword interface, you can easily define the interface. Interface classes specify what a class must do, instead of how to do it. Interface body contains the variables, but they are not counted as instance variables, and methods without any body, i.e. only the declaration of the methods are there.

 

Interface has to be implemented using implements keyword. If the interface is implemented in a concrete class then, in concrete class all the abstract method of the interface must be implemented. But if it is implemented in abstract class then only required methods have to be defined, others can be left, but in concrete class this abstract class will be extended, rest all the methods have to be implemented.

 

Interface works as a contract among the team members of a project. Some time there is a need to define fixed layout or model that has to be followed by everybody, yet each will have its own implementation, own code without bothering about the others code. They follow the same prototype. For example, a display 0 method can be a part of any class, but its definition will vary.

A class can extend one class and implements one or more interfaces simultaneously, the way how multiple inheritances can be possible in Java. An interface can extends any number of interfaces but one interface cannot implements another interface, because if any interface is implemented then its methods must be defined, and interface never has the definition of any method. Interface cannot be instantiated, but it can work as super class of any other class, so that, its reference variable can be created to store or refer to its sub-ordinate classes objects.

Implementation of Interfaces

The interface contains only method declarations. Interface does not allow the implementation of methods, so that method declaration is followed by a semicolon, but no braces. All methods declared in the interface are by default implicitly public, so no need to use public as prefix in declaration. Interface contains the data members as constants. These constant values are implicitly public, static, and final, these modifiers can be omitted.

 

Interface declaration can be headed by interface modifiers, those are as follows:

 

  1. public
  2. abstract
  3. strict floating point

 

Syntax to declare an interface:

 

modifier interface_name {

return_type methodNamel(parameter-list);

return_type methodName2(parameter-list);

type final-varNamel = value;

type final-varName2 = value;

}

 

Example:

 

interface Abc

{

void displayMsg();

}

public class DemoInterface implements Abc

{

public void displayMsg()

{

System.out.println(“This is implemented method of Abc interface”);

}

}

An interface can extends any number of interfaces. A demonstration is given below.

 

interface A

{

// …

}

interface B extends A

{

II …

}

interface C

{

// …

}

interface D extends B, C

{

// …

}

 

interface E

{

 //

}

class Abc

{

// …

}

class Xyz extends Abc implements D, E

{

// …

}

What is the Use of ‘FINAL’ Keyword?

By Dinesh Thakur

The final keyword has the following uses in the inheritance.

        If you want the method must not be overridden then defined that method as final.

 

Example:

 

class Abc

{

final public void dispaly()

{

System.out.println(“I am in Abc”);

}

}

class Xyz extends Abc

{

public void dispaly()

{

System.out.println(“I am in Xyz”);

}

}

 

At the time of compiler will show the error message given in the image.

                           Use of 'FINAL' Keyword

If you want to prevent a class from being inherited then declare that as final.

 

Example:

 

final class Abc

{

public void dispaly()

{

System.out.println(“I am in Abc”);

}

}

class Xyz extends Abc

{

public void dispaly()

{

System.out.println(“I am in Xyz”);

}

}

 

At the time of compiler will show the error message given in the image.

                         Final Keyword Error

If you want to create a constant then also use final with the variable declaration.

The methods declare as final, compiler is free to make inline calls for those methods. If a small final method is called, the compiler copies the bytecode of the final method as inline code to the calling method. The final method calls are resolved at compile time called, early binding.

What is Abstract Class in Java?

By Dinesh Thakur

An abstract class is one whose header contains the reserved keyword, abstract. An abstract class is distinguishable from other classes by the fact that it is not possible to use the new operator to construct objects from them directly. Each abstract class may have at least zero abstract methods.

Some time there is a situation in which you feel the need of a superclass that has only declaration of few or all methods, with definition of few or none methods. But it is necessary that it must not be a completely defined or implemented class. The methods are declared only and specified by abstract type modifier called abstract method.

An abstract method is a method prototype (i.e. return type, method name, list of parameters and optionally throws clause) without any implementation. Its implementation is provided by the subclass(es) of the class in which it is declared. To create an abstract method, simply specify the modifier abstract followed by the method declaration and replace the method body by a semicolon. To declare any method as abstract use the following form:

abstract accessmodifer returntype methodName(<parameterlist>);

A class can have one or more abstract methods, that class must also be declared as abstract. To declare a class as abstract, simply add abstract keyword before the class keyword in the first line of class definition. Abstract class cannot be instantiated, i.e. you cannot create an object with the new operator of abstract class. The construct cannot be abstract, and no method can be abstract static. Any concrete subclass has to implements all the abstract method of its abstract superclass. Abstract classes can be used to create object references. For example: The Shape superclass that contains abstract method area () will now look like,

abstract class Shape {

      abstract double area();//abstract method

      abstract double circumference();

}

Abstract classes are like normal classes with fields and methods but you cannot create objects of abstract classes using the new operater. However, you can declare a variable of an abstract class type. Such variables are used to manipulate subclass objects polymorphically. In other words, such variable can be used to refer to an instance of any of the subclasses of abstract superclass.
For example: If you try to instantiate an object of the abstract superclass Shape using the following statement,

Shape s = new Shape(3,4);// error, Shape abstract

It will result in compile time error. Moreover, it makes no sense to create Shape object. What dimensions would it have? What would be its area? .
Abstract classes are useful when you want to create a generic type that is used as a superclass for two or more subclasses, but the superclass itself does not represent an actual object. For example: As in case of Shape class which we need for inheritance and polymorphism but want only to instantiate objects of its subclasses, not Shape itself.

The following is java abstract class example.

//Show how to create abstract class and method

abstract class Shape {

      abstract void area();

      abstract void circumference();

}

class Rectangle extends Shape {

       private double length ,breadth;

       Rectangle(double x,double y) {

               length = x; breadth = y

       }

           public void area() {

                 System.out.println(“Area of Rectangle is = “ + (length*breadth));

                 public void circumference() {

                       System.out.println (“Circumference of Rectangle is=” +2* (lengthtbreadth));

                 }

           }

class Circle extends Shape {

          private double radius;

          Circle(double r) {

                 radius = r ;

          }

          public void area() {

              System.out.println(“Area of Circle is= “+( Math.PI*radius*radius));

          }

          public void circumference() {

              System.out.println(“Circumference of Circle is=”+ 2*Math.PI*radius);

          }

}

      class AbstractDemo {

             public static void main(String[] args) {

                 Shape s; //Shape class reference variable

                 Rectangle r = new Rectangle(10,20);

                 s = r; // Assign rectangle reference to shape reference

                 s.area();

                 s.circumference();

                 Circle c = new Circle(5);

                 s = c; //Assign circle reference to shape reference

                 s.area();

                 s.circumference();

             }

       }

The following points should be kept in mind while working with abstract classes.

• A subclass of an abstract class can be instantiated only if it overrides each of the abstract methods of its superclass and provides an implementation for each of them. Such classes are known as concrete classes (i.e. not abstract).
• If a subclass does not implements all the abstract methods that it inherits, the subclass must be specified as abstract.
• An abstract method cannot be private. Since a private method cannot be inherited and therefore cannot be overridden (redefined) in the subclass.
• Constructors and static methods cannot be declared abstract. As constructors cannot be inherited so an abstract constructor could never be implemented. Also as subclasses cannot override static methods, so an abstract static method cannot be implemented.
• An abstract class has no use, no purpose unless it is extended. However, abstract superclass names can be used to invoke the static methods declared in those abstract superclasses.
• By marking the class abstract, the compiler will stop any code, anywhere, from ever creating an instance of that type.
• Not all the methods in an abstract class have to be abstract.
• You can declare the class as abstract even if it does not have any abstract method. Such abstract class indicates that the implementation is incomplete and is meant to serve as a superclass for one or more subclasses that will complete the implementation.
• Class can’t specify both abstract and final. As the abstract class can only be used if you subclass it and final class cannot be subclassed.

Multiple Levels of Inheritance

By Dinesh Thakur

Java supports multilevel inheritance. In multiple, multilevel class hierarchies contain the layers of inheritance. But at each layer, a class is a subclass of the superc1ass of another, except the last layer. One pictorial representation of such concept is given below.

                                    Class Hierarchy of 4 classes

Example:

 

class Student

{

private int rollno;

private String name;

private String address;

public void storeDetails(int rno, String sname, String sadd)

{

rollno = rno;

name = sname;

address = sadd;

}

public void showDetails()

{

System.out.println(“ROll No :: ” + rollno);

System.out.println(“Name :: ” + name);

System.out.println(“Address :: ” + address);

}

}

class Test extends Student

{

protected int marksSubjectl;

protected int marksSubject2;

protected int marksSubject3;

protected int marksSubject4;

public void storeMarks(int ml, int m2, int m3, int m4)

{

marksSubjectl = ml;

marksSubject2 = m2;

marksSubject3 = m3;

marksSubject4 = m4;

}

public void showMarks()

{

System.out.println(“Marks of Subjectl :: ” + marksSubjectl);

System.out.println(“Marks of Subject2 :: ” + marksSubject2);

System.out.println(“Marks of Subject3 :: ” + marksSubject3);

System.out.println(“Marks of Subject4 :: ” + marksSubject4);

}

}

 

class Result extends Test

{

private int totalMarks;

private float percentage;

private char grade;

public void evaluateResult()

{

totalMarks = marksSubjectl + marksSubject2 + marksSubject3 + marksSubject4;

percentage = (totalMarks*100.00F/600.00F);

if (percentage >=50.00F)

grade=’D’;

else

if(percentage >=55.00F && percentage<=60.00F)

grade = ‘C’;

else

if (percentage >=61.00F && percentage<=70.00F)

grade = ‘B’;

else

if (percentage >=71.00F && percentage<=75.00F)

grade = ‘A’;

else

if (percentage >=76.00F && percentage<=85.00F)

grade = ‘H’;

else

grade = ‘S’;

}

public void showResult()

{

showDetails();

showMarks();

System.out.println(“Total Marks :: ” + totalMarks);

System.out.println(“percentage :: ” + percentage);

System.out.println(“Grade :: ” + grade);

}

}

public class Multilevellnheritance

{

public static void main(String ar[])

{

Result ob = new Result();

ob.storeDetails(1001, “Alice”, “New York”);

ob.storeMarks(135,130,132,138);

ob.evaluateResult();

ob.showResult();

}

}

 output

                       Multilevel inheritance

There can be few problems in multilevel inheritance, if the classes are not properly designed by the designer, or proper keywords art\ not used.

 

  1. How the superclass parameterized constructor will be called?
  2. If superclass and subclass protected or public data members have same name then, superclass data member will be hidden. How to distinguish or to access the superclass data member in the subclass?
  3. If subclass member methods have the same signature as the superclass member method then how to call the superclass member methods?

The super keyword is the solution of all the above problems, to refer to its immediate superclass. The super has two general forms as given below:

 

  1. To call the superclass constructor
  2. To access the hidden member of the superclass.

Example:

 

class Student

{

private int rollno;

private String name;

private String address;

public void storeDetails(int rno, String sname, String sadd)

{

rollno = rno;

name = sname;

address = sadd;

}

public void show()

{

System.out.println(“ROll No :: ” + rollno);

System.out.println(“Name :: ” + name);

system.out.println(“Address :: ” + address);

}

}

class Test extends Student

{

protected int marksSubjectl;

protected int marksSubject2;

protected int marksSubject3;

protected int marksSubject4;

public void test (int rno, String sname, String sadd,int ml, int m2, int m3, int m4)

{

super(rno,sname,sadd);

marksSubjectl = ml;

marksSubject2 = m2;

marksSubject3 = m3;

marksSubject4 m4;

}

 

public void show()

{

super.show();

System.out.println(“Marks of Subjectl :: ” + marksSubjectl);

System.out.println(“Marks of Subject2 :: ” + marksSubject2);

System.out.println(“Marks of Subject3 :: ” + marksSubject3);

System.out.println(“Marks of Subject4 :: ” + marksSubject4);

}

 

class Result extends Test

{

private int totalMarks;

private float percentage;

private char grade;

public void Result(int rno, String sname, String sadd,int ml, int m2, int m3, int m4)

{

super(rno,sname,sadd,ml,m2,m3,m4);

 

totalMarks = marksSubjectl + marksSubject2 + marksSubject3 + marksSubject4;

percentage = (totalMarks*100.00F/600.00F);

if (percentage >=50.00F)

grade=’D’;

else

if(percentage >=55.00F && percentage<=60.00F)

grade = ‘C’;

else

if (percentage >=61.00F && percentage<=70.00F)

grade = ‘B’;

else ,

if (percentage >=71.00F && percentage<=75.00F)

grade = ‘A’;

else

if (percentage >=76.00F && percentage<=85.00F)

grade = ‘H’;

else

grade = ‘S’;

}

public void show()

{

super.show();

System.out.println(“Total Marks :: ” + totalMarks);

System.out.println(“percentage :: ” + percentage);

System.out.println(“Grade :: ” + grade);

}

}

public class MultilevellnheritanceDemo2

{

public static void main(String arg[])

{

Result ob = new Result (1001, “Alice”, “New York“, 135,130,132,138);

ob.show ();

}

 

The above code show how to call the superclass constructor and how to call the superclass method if that signature is same as the subclass method signature.

 

Example:

 

class Abc

{

int i;

public Abc(int i)

{

this.i= i;

}

}

class Xyz extends Abc

 

{

int i,j;

public Xyz(int a,int b)

{

super(a);

j=b;

i = ++(super.i);

}

public void showAll()

{

System.out.println(“Superclass ‘i’ :: “+super.i);

System.out.println(“Subclass ‘i’ :: ” + i +” ‘j’ :: “+ j);

}

}

public class MultilevellnheritanceDemo

{

public static void main(String arg[])

{

Xyz ob = new Xyz(1,2);

ob.showAll();

} }

 

Output:.

 

Superclass ‘i’ :: 2

Subclass ‘i’ :: 2 ‘j’:: 2

 

In the above code, in subclass the data member of superclass ‘i’ hides with subclass data member ‘i’, so that using super keyword it access .

What are the Access Attributes in java?

By Dinesh Thakur

The class member attributes (fields) and methods are bounded with some accessibility modifier, which defines the access scope of the member. In this section, we’ll study how to access the data members (attributes) of the class.

 

All the public and protected members of the parent of subclass always inherit, doesn’t matter what package the subclass is in.

  1. Just like any other fields of the subclass, the inherited fields can be used.
  2. If you declare a field in the subclass, with the same name as in superclass, then the subclass field will hide the superclass inherited filed.
  3. The inherited method can be used as same as the subclass method are used.
  4. You can define a new instance method in the subclass, that has the same signature as one of the superclass method, called overriding.
  5. You can define a new static method (class member) for the subclass, that has the same signature as one of the superclass method, called hiding.
  6. The subclass constructor invokes the superclass constructor either implicitly if the superclass constructor is default or by using the keyword super.

 

The attributes can be with any access modifier like private, protected, public, and default. There is fixed scope of accessibility or extendibility of the attribute in subclass. The attributes will be inherited or not, it totally depends on its access modifier. There are four access modifiers as follows with its scope:

 

  1. 1.private: never inherit
  2. 2.protected: only in its subclass
  3. 3. public : inherit
  4. 4.default: inherit

 

Example:

 

//Create a superclass

 

class SuperClass

{

private int a;

protected int b;

public int c;

int d;

public void storeab()

{

a = 41;

b = 41;

c = 41;

d = 41;

}

public void showab()

{

 

System.out.println(“SuperClass contents :: a = “+a+” b “+b+” c “+c+” d = “+d);

}

}

 

//Create a sub class by extending class SuperClass

 

class SubClass extends SuperClass

{

int s;

public void sumab()

{

s=a+b+c+d;

s = b+c+d;

}

public void shows()

{

System.out.println(“SubClass contents:: s = “+s);

 

}

}

 

public class SingleInheritanceDemo

{

public static void main(String arg[])

{

SubClass ob = new SubClass();

ob.storeab();

ob.sumab ();

ob.showab ();

ob.shows();

} }

 

When you compile this code you’ll find the following message:

                           Single Inheritance Error

But if you want the value of attribute ‘a’ in subclass then either implement a method that returns its value or define it as default or public. The modified version of the program is given below with definition of a method that returns the value of attribute ‘a’ of SuperClass.

 

//Create a superclass

 

class SuperClass

{

private int a;

protected int b;

public int c;

int d;

public void storeab()

{

a = 41;

b = 41;

c = 41;

d = 41;

}

public void showab()

{

 

System.out.println(“SuperClass contents :: a = “+a+” b “+b+” c “+c+” d = “+d);

}

 

public int geta()

{

return a;

}

}

 

//Create a sub class by extending class SuperClass

 

class SubClass extends SuperClass

{

int s;

public void sumab()

{

s=a+b+c+d;

s = b+c+d;

}

public void shows()

{

System.out.println(“SubClass contents:: s = “+s);

 

}

}

 

public class SingleInheritanceDemo

{

public static void main(String arg[])

{

SubClass ob = new SubClass();

ob.storeab();

ob.sumab ();

ob.showab ();

ob.shows();

} }

 

The protected, public and default field ‘b’, ‘c’ and ‘d’ are inherited in subclass .

Reusability of Existing Classes

By Dinesh Thakur

 For the reusability of existing classes, inheritance came into use, and java supports only two types of inheritance, in which a class extends another class.

  1. 1.Single Inheritance
  2. 2.Multilevel Inheritance

 

In Java, a class can be derived from another class using the general form:

 

access_specifier class Subclass extends Superclass

{

//Derived class data and methods

}

 

Various types of inheritance are discussed in the section below.

 

Single Inheritance

 

In this type of inheritance, a single sub class is derived from a single base class.

                                Single Inheritance

Multiple Inheritances

 

In multiple inheritances, there is more than one base class from which the child class is derived. This results in the duplication of data with the derived class. This is a major problem with OOP and a mechanism called Virtual Base Class is provided for this, in which, one of the base classes is made virtual to avoid the duplicate inheritance of data.

                                  Multiple Inheritance

Java does not directly support multiple inheritances. This is because different classes may have different variables with same name that may be contradicted and can cause confusions in JVM, thus resulting in errors. Java only supports multiple inheritances when used with Interfaces. We can extend one class only to avoid ambiguity problem with JVM. In interface we have to define the functions. So there is no ambiguity. In C++, it is big problem but in JAVA this issue has been improved by introducing Interfaces.

 

Multilevel Inheritance

 

In multilevel inheritance, a class derives another class, and from the derived class, another sub class is derived.

                                               Multilevel Inheritance

Hybrid Inheritance

 

There may occur situations where we need to apply two or more types of inheritance in the design of a program. For such cases, hybrid inheritance is used.

                                              Hybrid inhertance

Multiple inheritances cannot be possible by extending more than one class, it can be possible with one another and important features of the Java, called interface.

 

To inherit a class into another class extends keyword is used.

 

class subclassName extends superclassName

{

//body of subclass

}

 

The most important point in inheritance is that, the subclass object will be created and all the accessible members of superclass and its own are accessed by subclass object.

 

Example:

 

// Create a superclass

class SuperClass

{

int a,b;

public void storeab()

{

a = 41;

b = 41;

}

public void showab()

{

System.out.println(“SuperClass contents :: a = “+a+” b = “+b);

}

}

//Create a sub class by extending class SuperClass

class SubClass extends SuperClass

{

int s;

public void sumab ()

{

s=a+b;

}

public void shows()

{

System.out.println(“SubClass contents:: s = “+s) ;

}

}

public class SingleInheritance

{

public static void main(String arg[])

{

SubClass ob = new SubClass();

ob.storeab ();

ob.sumab();

ob.showab();

ob.shows();

}

}

 

Output:

                                   Single Inheritance

In the give example, the object of the class SubClass, ob, is used to call the public member of it’s superclass as well as it’s own. So that we can observe, that the public member of SuperClass are inherited in the SubClass, i.e. become the part of it, so that using ob, we’re able to call them or access them. In the method sumab() of SubClass, we are directly using the a,b of SuperClass without using any instance of SuperClass, because these are inherited in the Subclass. The fields are without any access modifier, count under the category of default access modifier, and methods are defined as public.

What is Class Inheritance?

By Dinesh Thakur

Inheritance is one of the most dominant and vital feature of the object oriented programming because it supports the hierarchical classifications, reusability of class; and defined to specialization. Java is a language that supports inheritance but with some additional advantages and features. [Read more…] about What is Class Inheritance?

Java’s Magic: The Byte Code

By Dinesh Thakur

The means that allows Java to solve both the security and the portability problems is that the output of a Java compiler is not executable code but it is the Bytecode. Bytecode is a highly optimized set of instructions designed to be executed by the Java run-time system, which is called the lava Virtual Machine (JVM). JVM is an interpreter for bytecode. The fact that a Java program is executed by JVM helps solve the major problems associated with downloading programs over the Internet. Translating a Java program into bytecode helps makes it much easier to run a program in a wide variety of environments. This is because only the JVM needs to be implemented for each platform. [Read more…] about Java’s Magic: The Byte Code

Difference Between Type Conversion and Type Casting

By Dinesh Thakur

In computer science, “type casting” and “type conversion” refers when there is either implicitly or explicitly is a conversion from one data type to another. When both types of expression are compatible with each other, then Data type conversions from one type to another can be carried out Automatically by java compiler. However, there is a technical difference between type conversion and type casting, i.e. type conversion is carried out “automatically” by java compiler while the “type casting” (using a cast operator) is to be explicitly performed by the java programmer.It is usually classified into two categories [Read more…] about Difference Between Type Conversion and Type Casting

What is Java keyword (reserved words)? – Definition

By Dinesh Thakur

Keywords also are known as reserved words are the pre-defined identifiers reserved by Java for a specific purpose that inform the compiler about what the program should do. A Keyword is that which have a special meaning those already explained to the java language like int, float, class, public, etc. these are the reserved keywords. These special words cannot be used as class names, variables, or method names, because they have special meaning within the language.
[Read more…] about What is Java keyword (reserved words)? – Definition

Java Tokens – What is Java Tokens?

By Dinesh Thakur

Java Tokens:- A java Program is made up of Classes and Methods and in the Methods are the Container of the various Statements And a Statement is made up of Variables, Constants, operators etc .  [Read more…] about Java Tokens – What is Java Tokens?

Java Literals – What is literal in Java? Type of literal

By Dinesh Thakur

Java Literals: A literal in java refers to a fixed value that appears directly in a program. Java define five primary types of literals. By literal we mean any number, text, or other information that represents a value. This means what you type is what you get. They are commonly known as constants. We will use literals in addition to variables in Java statement. [Read more…] about Java Literals – What is literal in Java? Type of literal

What is an identifiers in Java? – Definition

By Dinesh Thakur

Identifiers in Java. A Java identifier is the symbolic name that is used for identification purpose. In Java, an identifier can be a variable name, constant name, method name, class name, array name, packages name or an interface. Few authors term variables as an identifier. For example : int score = 100; [Read more…] about What is an identifiers in Java? – Definition

Final Keyword in java

By Dinesh Thakur

There are times when you want to prevent inheritance. Perhaps there is no need the extensibility for various reasons. If you know this for sure, there are advantages to declaring the final keyword precisely that. [Read more…] about Final Keyword in java

What is Key words?Explain Type of Keyword

By Dinesh Thakur

Keywords are the words. Those have specifics meaning in the compiler.

Those are called keywords. There are 49 reserved keywords currently defined in the java language. These keywords cannot be used as names for a variable, class or method. Those are, [Read more…] about What is Key words?Explain Type of Keyword

Type Casting in Java

By Dinesh Thakur

Type Casting: The process of converting one data type to another is called casting. Casting is often necessary when a function returns a data of type in different form then we need to perform an operation. Under certain circumstances Type conversion can be carried out automatically, in other cases it must be “forced” manually (explicitly). For example, the read() member function of the standard input stream (System.in) returns an int. If we want to store data of type int returned by read() into a variable of char type, we need to cast it : [Read more…] about Type Casting in Java

New Keyword – What is New Keyword?

By Dinesh Thakur

New is a Keyword Which is used when we are Creating an object of class For Storing all the data like variables and member functions  of class  there is some memory Space that is to be needed So that With the help of new Keyword and Object is Instantiated or Simply an object Reserves

 Some Memory or Some New Memory is Allocated to Class Object For Storing  data and member functions of Class So Every Object Must be Created With the Help of New Keyword So For Allocating New Memory Area .

Constant – What is Constant? Type of Constant

By Dinesh Thakur

Constants: Constants in java are fixed values those are not changed during the Execution of program. A literal is a constant value that can be classified as integer literals, string literals and boolean literals. To make a static field constant in Java, make a variable as both static and final. java supports several types of Constants  those are  

Integer Constants:  Integer Constants refers to a Sequence of digits which Includes only negative or positive Values and many other things those are as follows

• An Integer Constant must have at Least one Digit.
• it must not have a Decimal value.
• it could be either positive or Negative.
• if no sign is Specified then it should be treated as Positive.
• No Spaces and Commas are allowed in Name.

Real Constants:

• A Real Constant must have at Least one Digit.
• it must have a Decimal value.
• it could be either positive or Negative.
• if no sign is Specified then it should be treated as Positive.
• No Spaces and Commas are allowed in Name.

Like 251, 234.890 etc are Real Constants.

In The Exponential Form of Representation the Real Constant is Represented in the two Parts The part before appearing e is called mantissa whereas the part following e is called Exponent.

• In Real Constant The Mantissa and Exponent Part should be Separated by letter e.
• The Mantissa Part have may have either positive or Negative Sign.
• Default Sign is Positive.

Single Character Constants

A Character is Single Alphabet a single digit or a Single Symbol that is enclosed within Single inverted commas.

Like ‘S’ ,’1’ etc are Single  Character Constant.

String Constants:  String is a Sequence of Characters Enclosed between double Quotes These Characters may be digits ,Alphabets  Like “Hello” , “1234” etc.

Backslash Character Constants: Java Also Supports Backslash Constants those are used in output methods For Example \n is used for new line Character These are also Called as escape Sequence or backslash character Constants For Ex:    

\t  For Tab  ( Five Spaces in one Time ).

\b Back Space etc.

final Variable (OR Constant Variable)

Variables are useful when you need to store information that can be changed as program runs. However, there may be certain situations in the program in which the value of variable should not be allowed to modify. This is accomplished using a special type of variable known as final variable. The final variable also called constant variable. It is a variable with a value that cannot be modified during the execution of the program.

To declare a final variable, use the final keyword before the variable declaration and initialize it with a value. Its syntax is

final datatype varName = value;

For example:

final double PI = 3.141592;

This statement declares a variable PI of type double which is initialized to 3.141592, that cannot be modified. If an attempt is made to modify a final variable after it is initialized, the compiler issues an error message “cannot assign a value to final variable PI”.

You can also defer the initialization of final variable, such a final variable is know as blank final. However, it must be initialized before it is used.
Final variables are benefitical when one need to prevent accidental change to method parameters and with variables accessed by anonymous class.
Now consider a program to calculate the area of the circle,

//Area of the circle
public class AreaCircle {
    public static void main(String[] args) {
        int r = 10; // initializing radius
        final double PI = 3.141592 //final variable
        double area;
        //PI = 3.142; will generate an error
        area = PI * r * r;
        System.out.println(“Area of circle is –>” +area);
     }
}
Output: Area of circle is — >314.1592
NOTE: It is recommended to declare a final variable in uppercase

What is Identifiers,Literals,Operator and Separators

By Dinesh Thakur

Identifiers :- The Identifiers are those which are used for giving a name to a variable  ,class and method ,packages ,interfaces etc There Are Some Rules against for using the Identifiers

 

  • Name of Identifier not be a Keyword
  • Must be Start from Alphabet not from digit
  • Uppercase and Lowercase are Different
  • Can be any length

 

Literals :- Literals are Sequence of Characters like Digits ,alphabets ,letters those are used for Representing the Value of the Variable  Like Integer Literals, String Literals, Float Literals

 

Operator:- operators are the Special Symbols those have  specific functions associated with them for Performing the operations it needs some Operands

 

        Operands are those on which operations are performed by the Operators

        Like  2 +3

        In this + is the Operator and 2 and 3 Operands.

 

Separators :- These are Special Symbols used to Indicate the group of code that is either be divided or arrange into the Block The Separators includes Parentheses, Open Curly braces  Comma, Semicolon, or either it will  be period or dot Operator

 

Java Operator | Types of Operator in Java

By Dinesh Thakur

An operator is a special symbol that tells the compiler to perform a specific mathematical or logical operation on one or more operands where an operand can be an expression. An operation is an action(s) performed on one or more operands that evaluates mathematical expressions or change the data. [Read more…] about Java Operator | Types of Operator in Java

What are OOP Concepts in Java? – Definition & Examples

By Dinesh Thakur

All the Previous Languages are Structured or we can say that they were procedural programming means in them processing is to be done in sequence manner and These are also called the Top down or either they were bottom up Languages Most Important things those must be in the Languages are Reliability, Maintainability and Reusability and user Friendly So For Achieving these things they Developed java. [Read more…] about What are OOP Concepts in Java? – Definition & Examples

Features of java

By Dinesh Thakur

1) Compiled and Interpreter: has both Compiled and Interpreter Feature Program of java is First Compiled and Then it is must to Interpret it .First of all The Program of java is Compiled then after Compilation it creates Bytes Codes rather than Machine Language. [Read more…] about Features of java

Explain Differences Between C , C++, and Java

By Dinesh Thakur

Language: C is a powerful, efficient, general purpose structured programming language. Although C is a high level language but it also supports features of a low level language, so it is sometimes called a middle level language. It is actually binding the gap between a machine language and more conventional high level languages. c++ is partial copy of object oriented programming language that allow programmers to build large and complex applications in a useful and efficient way. [Read more…] about Explain Differences Between C , C++, and Java

Differences Between C++ and Java

By Dinesh Thakur

C++ and Java both are Object Oriented Languages but some of the features of both languages are different from each other. Some of these features are : [Read more…] about Differences Between C++ and Java

Java Virtual Machine (JVM) & its Architecture

By Dinesh Thakur

What is JVM (Java Virtual Machine): Most programming languages such as C/C++ compile source code directly into machine code suitable for execution on a particular microprocessor architecture or operating systems such as Windows or Unix. This property does not make these languages’ architecturally neutral’. However, Java is an architectural neutral language as it follows. Write once execute anywhere approach. This feature of Java achieved as the Java compiler does not translate the source code into the machine language of the computer that the program is running on. Instead, the compiler translates source code into bytecode which is not understood by the underlying operating system. So an application is needed that can convert this bytecode into machine code understood by the underlying operating system. It is accomplished using the Java Virtual Machine. [Read more…] about Java Virtual Machine (JVM) & its Architecture

Java Runtime Enviroment

By Dinesh Thakur

The JRE is the smallest set of executables and files that constitute the standard java plot form.The Java Runtime Environment (JRE) provides the libraries, the Java Virtual Machine, and other components to run applets and applications written in the Java programming language. In addition, two key deployment technologies are part of the JRE: [Read more…] about Java Runtime Enviroment

« Previous Page
Next Page »

Primary Sidebar

Java Tutorials

Java Tutorials

  • Java - Home
  • Java - IDE
  • Java - Features
  • Java - History
  • Java - this Keyword
  • Java - Tokens
  • Java - Jump Statements
  • Java - Control Statements
  • Java - Literals
  • Java - Data Types
  • Java - Type Casting
  • Java - Constant
  • Java - Differences
  • Java - Keyword
  • Java - Static Keyword
  • Java - Variable Scope
  • Java - Identifiers
  • Java - Nested For Loop
  • Java - Vector
  • Java - Type Conversion Vs Casting
  • Java - Access Protection
  • Java - Implicit Type Conversion
  • Java - Type Casting
  • Java - Call by Value Vs Reference
  • Java - Collections
  • Java - Garbage Collection
  • Java - Scanner Class
  • Java - this Keyword
  • Java - Final Keyword
  • Java - Access Modifiers
  • Java - Design Patterns in Java

OOPS Concepts

  • Java - OOPS Concepts
  • Java - Characteristics of OOP
  • Java - OOPS Benefits
  • Java - Procedural Vs OOP's
  • Java - Polymorphism
  • Java - Encapsulation
  • Java - Multithreading
  • Java - Serialization

Java Operator & Types

  • Java - Operator
  • Java - Logical Operators
  • Java - Conditional Operator
  • Java - Assignment Operator
  • Java - Shift Operators
  • Java - Bitwise Complement Operator

Java Constructor & Types

  • Java - Constructor
  • Java - Copy Constructor
  • Java - String Constructors
  • Java - Parameterized Constructor

Java Array

  • Java - Array
  • Java - Accessing Array Elements
  • Java - ArrayList
  • Java - Passing Arrays to Methods
  • Java - Wrapper Class
  • Java - Singleton Class
  • Java - Access Specifiers
  • Java - Substring

Java Inheritance & Interfaces

  • Java - Inheritance
  • Java - Multilevel Inheritance
  • Java - Single Inheritance
  • Java - Abstract Class
  • Java - Abstraction
  • Java - Interfaces
  • Java - Extending Interfaces
  • Java - Method Overriding
  • Java - Method Overloading
  • Java - Super Keyword
  • Java - Multiple Inheritance

Exception Handling Tutorials

  • Java - Exception Handling
  • Java - Exception-Handling Advantages
  • Java - Final, Finally and Finalize

Data Structures

  • Java - Data Structures
  • Java - Bubble Sort

Advance Java

  • Java - Applet Life Cycle
  • Java - Applet Explaination
  • Java - Thread Model
  • Java - RMI Architecture
  • Java - Applet
  • Java - Swing Features
  • Java - Choice and list Control
  • Java - JFrame with Multiple JPanels
  • Java - Java Adapter Classes
  • Java - AWT Vs Swing
  • Java - Checkbox
  • Java - Byte Stream Classes
  • Java - Character Stream Classes
  • Java - Change Color of Applet
  • Java - Passing Parameters
  • Java - Html Applet Tag
  • Java - JComboBox
  • Java - CardLayout
  • Java - Keyboard Events
  • Java - Applet Run From CLI
  • Java - Applet Update Method
  • Java - Applet Display Methods
  • Java - Event Handling
  • Java - Scrollbar
  • Java - JFrame ContentPane Layout
  • Java - Class Rectangle
  • Java - Event Handling Model

Java programs

  • Java - Armstrong Number
  • Java - Program Structure
  • Java - Java Programs Types
  • Java - Font Class
  • Java - repaint()
  • Java - Thread Priority
  • Java - 1D Array
  • Java - 3x3 Matrix
  • Java - drawline()
  • Java - Prime Number Program
  • Java - Copy Data
  • Java - Calculate Area of Rectangle
  • Java - Strong Number Program
  • Java - Swap Elements of an Array
  • Java - Parameterized Constructor
  • Java - ActionListener
  • Java - Print Number
  • Java - Find Average Program
  • Java - Simple and Compound Interest
  • Java - Area of Rectangle
  • Java - Default Constructor Program
  • Java - Single Inheritance Program
  • Java - Array of Objects
  • Java - Passing 2D Array
  • Java - Compute the Bill
  • Java - BufferedReader Example
  • Java - Sum of First N Number
  • Java - Check Number
  • Java - Sum of Two 3x3 Matrices
  • Java - Calculate Circumference
  • Java - Perfect Number Program
  • Java - Factorial Program
  • Java - Reverse a String

Other Links

  • Java - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2025. All Rights Reserved.

APPLY FOR ONLINE JOB IN BIGGEST CRYPTO COMPANIES
APPLY NOW