Method Overloading in Java

class MethodOver { int n1; int n2; MethodOver() { n1 = 10; n2 = 20; } void square() { System.out.println(“\n\n\tThe Square is ” + n1 * n2); } void square(int p1) { n1 = p1; System.out.println(“\n\n\tThe Square is ” + n1 * n2); } void square(int p1, int p2) { n1 = p1; n2 =

StringBuffer class in java

import java.util.*; class strbuf1 { public static void main(String args[]) { StringBuffer s1 = new StringBuffer(); StringBuffer s2 = new StringBuffer(“Hello World”); StringBuffer s3 = new StringBuffer(s2); StringBuffer s4 = new StringBuffer(100); System.out.println(“s1 = ” + s1); System.out.println(“s2 = ” + s2); System.out.println(“s3 = ” + s3); System.out.println(“s1.length = ” + s1.length()); System.out.println(“s2.length = ”

Thread Tutorial in Java

public class Main { public static void main(String[] args) { Thread t1 = Thread.currentThread(); ThreadGroup tg1 = t1.getThreadGroup(); System.out.println(“Current thread’s  name:  ” + t1.getName()); System.out.println(“Current thread’s  group  name:  ” + tg1.getName()); Thread t2 = new Thread(“my  new thread”); ThreadGroup tg2 = t2.getThreadGroup(); System.out.println(“New  thread’s name:  ” + t2.getName()); System.out.println(“New  thread’s  group  name:  ” + tg2.getName());

Multilevel Hierarchy in java

class student { int rollno; String name; student(int r, String n) { rollno = r; name = n; } void dispdatas() { System.out.println(“Rollno = ” + rollno); System.out.println(“Name = ” + name); } } class marks extends student { int total; marks(int r, String n, int t) { super(r,n); total = t; } void dispdatam()