Posts Tagged javanepal

Hardest Programming Language

In my view the toughest programming language is C# and JAVA cuz they have very vast library and their code are tough enough.

Post comment according to your opinion about this topic:

Tags: , , , , , ,

Accepting Keyboard Input

First of all we need to know that in java for printing the line we use following command:

System.out.println();
While we code the System then it is related with input and output and all the hardware conf.
Then the keyword out defines about the display of the line.
Now we need to input instead of output.
So just code by following ways:
System.in.read();
Read the rest of this entry »

Tags: , , , , , , , ,

Interface Class

Actually Interface are just like a class where it consists only constants and they
We can extend interface via interfaces
We can implement the interface via classes.
In interface needn’t use the “public” or “abstract” keywords – all methods
declared by an interface are automatically public and abstract by default.
A simple example of interface implement is given below.
[sourcecode=’java’]
public interface testInterface {
//one of the method without method body
void disp(String text);
}[/sourcecode]
For implementing this interface through normal class we follow below step: Read the rest of this entry »

Tags: , , ,

Static method

[sourcecode=’java’]
public class Student {

private static int totalStudents;

// Other details omitted.
// Constructor.

public Student() {

// Details omitted.
// Automatically increment the student count every time we
// instantiate a new Student.

totalStudents++;

}

// The following three methods are now static methods; .

public static int getTotalStudents() {
return totalStudents;
}

public static void setTotalStudents(int x) {
totalStudents = x;
}

public static void reportTotalEnrollment() {
System.out.println(“Total Enrollment: ” + getTotalStudents());
}

public static void main (String[] args) {
//Static methods can be invoked from a class filename

//or invoke it from the object related class
setTotalStudents(4);
reportTotalEnrollment();
//optional

/*
*Student s1 = new Student();
*s1.setTotalStudent();
*s1.reportTotalEnrollment();
*/

}

}
[/sourcecode]

Tags: , , ,

Polymorphism on three classes

This Polymorphism is one of the special feature of OOPL(Object oriented Programming Language). The polymorphism can perform several functions with a single method. A simple example of Polymorphism is given below according to real world.

polymorphism

fig. Polymorphism in real world

The term polymorphism refers to the ability of two or more objects belonging to different classes to respond to exactly the same message (method call) in different class-specific ways. Read the rest of this entry »

Tags: ,