Core Java Source Code news

You can get Core Java Sample application and code for all core java Concepts in this page.

Super Keyword in Java with example

Super Keyword in Java with example. You can find Super keyword example Program (code snippets) in this page. class Base1{ protected int num; public Base1(int n){ num = n; System.out.println(“\n\t1-parameter constructor of Base class.”); } public void display(){ System.out.println(“\n\tDisplay of Base class: ” + num); } } class Derived1 extends Base1{ private int num; public… Read More »

Multiple Inheritance Example Program in Java

Multiple Inheritance Example Program in Java. You can find multiple inheritance example program (code snippets) in this page. interface First{ void disp(); } interface Second extends First{ void show(); } abstract class Shape1{ abstract void draw(); } class Rectangle1 extends Shape1 implements First{ public void draw(){ System.out.println(“Inside draw”); } public void disp(){ System.out.println(“inside disp”); }… Read More »

Inheritance Example Program in Java

Inheritance Example Program in Java. You can find inheritance example program (code snippets) in this page. class Base{ private int num; public Base(){ num = 100; System.out.println(“\n\tDefault constructor of Base class.”); } public void displayNum(){ System.out.println(“\n\tValue of num: ” + num); } } class Derived extends Base{ private int data; public Derived(){ data = 200;… Read More »

Dynamic Binding Example in Java

Dynamic Binding Example in Java. You can find dynamic binding Concept with Example Program (code snippets) in this page. class Shape{ public void draw()         { System.out.println(“\n\tDrawing a shape.”); } } class Circle extends Shape{ public void draw()         { System.out.println(“\n\tDrawing a Circle.”); } } class Rectangle extends Shape{ public void draw()         { System.out.println(“\n\tDrawing a Rectangle.”); }… Read More »

Abstract Class Example in Java Program

Abstract Class Example in Java Program. You can find Abstract Class, Abstract method, Abstract Concept program (code snippets) in this page. abstract class Shape{ abstract void draw(); } class Rectangle extends Shape{ void draw(){ System.out.println(“Drawing Rectangle”); } } class Traingle extends Shape{ void draw(){ System.out.println(“Drawing Traingle”); } } class AbstractDemo{ public static void main(String args[]){… Read More »

Static Method in Java Example Program

Static Method in Java Example Program. You can find Static member method in Java with Example Program (code snippets) in this page. class StaticMemberMethod{ private static int count; private static int data; static{ count = 0; } public StaticMemberMethod(){ count++; } public static void displayCount() { data = 123; System.out.println(“\n\tCount value is: ” + count);… Read More »

Method Overloading Example in Java

Method Overloading Example in Java. You can find method overloading in Java Program (code snippets) in this page. class MethodOverloading{ public void display(int num){ System.out.println(“\n\tInteger value: ” + num); } public void display(float value){ System.out.println(“\n\tFloat value: ” + value); } public void display(char ch){ System.out.println(“\n\tCharacter value: ” + ch); } } public class MethodOverloadingDemo{ public… Read More »

Constructor Overloading in Java With Example

class Student3{ private int rollNumber; private String name; public Student3()               { System.out.println(“Inside Default Constructor”); rollNumber=0; name=””; } public Student3(int rollNumber,String name)             { System.out.println(“Inside Overloaded Constructor”); this.rollNumber=rollNumber; this.name=name; } public void displayStudent()                   { System.out.println(“rollno= “+rollNumber+”name “+name); } } class ConstructorOverLoad{ public static void main(String arg[]) { Student3 s1=new Student3(101,”jack”); s1.displayStudent(); Student s2=new Student(); s2.displayStudent(); } }… Read More »

Constructor in Java Example – Java Constructor Example Program

Constructor in Java Example – Java Constructor Example Program. You can find Source code (code snippets) for Constructor in Java. class Test{ int studentId; public Test(int studentId){ this.studentId=studentId; } public int getId(){ return studentId; } } public class Constructor{ public static void main(String args[]){ Test t=new Test(50); System.out.println(t.studentId); System.out.println(t.getId()); } } Result: 50 50

Java Class Example – Class in Java Example Program

Java Class Example – Class in Java Example Program. You can find Source code for Class in Java. class Student{ int rollNumber = 101; String name = “eshusoft”; void setStudent(int rno,String sname){ rollNumber=rno; name=sname; } void display(){ System.out.println(“rollNumber =”+rollNumber); System.out.println(“name =”+name); } } public class ClassDemo { public static void main(String[] args) { Student obj… Read More »

Java String Example Program – String Java Example

Java String Example Program – String Java Example. class CheckString{ public static void main(String args[]){ String str=”HELLO guys”; System.out.println(“The String is:” + str); System.out.println(“Length of the String is:” + str.length()); System.out.println(“Character at specified position:” + str.charAt(4)); System.out.println(“substring of the String is:” + str.substring(6,10)); System.out.println(“Index of the specified character:” + str.indexOf(“g”)); System.out.println(“conversion to uppercase:” + str.toUpperCase());… Read More »