Skip to main content

Learn advanced java tutorial programs

Hi there, every program discussed on my java youtube course is available here:








package com.tamilhacks.New;

public class Dummy {

    public void display1(){
        System.out.println("dummy");
    }
}

1. Abstract.java


package com.tamilhacks;

abstract class Bike{
    void run(){

    }

    abstract void running(); //declarion

}

class pulsar extends Bike{  // concrete class

    void running(){  //define
        System.out.println("running");
    }

}


public class Abstract {

    public static void main(String[] args) {
        System.out.println("Abstract");
        Bike obj = new pulsar();
        obj.run();
        obj.running();

    }
}

2. Constructor.java


package com.tamilhacks;

class Car{

    int speed;
    String color;




    Car(){
        speed = 100;
        color = "Black";
        System.out.println("default constructor is running");

    }


    Car(int i){
        speed = i;
        System.out.println("int i constructor is running");

    }

    Car(String i,int i1){

    }

    Car(int s ,String c){
        speed = s;
        color = c;
        System.out.println("int s,c constructor is running");

    }

    public void run(){
        System.out.println("car is running");
    }

}

public class Constructor {




        public static void main(String[] args) {
            System.out.println("hi guys");

            int number ;

            //Car audi = new Car();
            //audi.color = "Black";
            //class name


            Car bmw = new Car(200,"black");
            // bmw.speed = 200;
            // bmw.color = "White";

            //audi.run();
            System.out.println(bmw);


        }


    }

3. Encapuslation.java


package com.tamilhacks;

class data{
    private int id;
    private String password;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
    //getters and setters

}


public class Encapsulation {
    public static void main(String[] args) {
        System.out.println("Encapsulation");
        data obj = new data();



    }
}


4. Exception Handling.java


package com.tamilhacks;

import java.util.Scanner;

public class Exceptionhandling {
    public static void main(String[] args) {
        System.out.println("Exception Handling");

        try{
            int number ;  //wrong
            Scanner input = new Scanner(System.in);
            number = input.nextInt();
            System.out.println(number);
        }catch (ArithmeticException a){

        }

        catch (Exception ex){
            System.out.println("only number values are accepted");
        }
        finally {
            System.out.println("always execute");
        }

        //throw
        try{
            int num = 101 ;
            if( num == 10)
                throw new Exception();

        }
        catch (Exception e){
            System.out.println("yes");
        }

    }
}


5. final.java

package com.tamilhacks;


//final class
class Cons{

    final void display(){
        int i  = 100;
        System.out.println("100");

    }

}

class ok extends Cons{

}

public class Final {
    public void dis(){
        System.out.println("Final");
        final int i = 10;
        ok obj = new ok();
        obj.display();
    }
}


6. Inheritance.java


package com.tamilhacks;
class add{  //super , parent

    add(){

    }
    add(int a , int b){
        System.out.println(a+b);

    }

    void run(){
        System.out.println("this is add class");
    }
}

class sub extends add { //sub , child
    void run2(){
        System.out.println("this is sub class");
    }
}

class mul extends add  { //multi level , multiple a-b-c ,normal a-b , hier a-b , a-c
    //add , sub
}

//is -a , has - a
public class Inheritance {

    public static void main(String[] args) {
        System.out.println("inheritance");

        mul s = new mul();
        s.run();
        //s.run2();

    }

}


7.  package.java



package com.tamilhacks;

import com.tamilhacks.New.Dummy;

import com.tamilhacks.New.Dummy;

import java.util.Arrays;

public class Package {
    public static void main(String[] args) {
        System.out.println("package & imports");

        Rough obj = new Rough();
        obj.display();

        Dummy obj1 = new Dummy();
        obj1.display1();


    }
}


8.  rough.java


package com.tamilhacks;

public class Rough {

    public void display(){
        System.out.println("rough");
    }

    //empty - not accessible in other package
    //public - can use everywhere
    //private = only in that class
    //protected = only in that package
}


9. static.java 

package com.tamilhacks;

class Student{
    int rollNo;
    int class_;
    static String principal ;

    static {
        principal = "raju";
    }

    void display(){
        System.out.println("hi");
    }

}

public class Static {

    public static void main(String[] args) {
        System.out.println("Static keyword");
        Student karthik = new Student();
        karthik.rollNo = 120120;
        karthik.class_ = 12;
        //Student.principal = "raju";

        Student vimal = new Student();
        vimal.rollNo = 120123;
        vimal.class_ = 11;
        // vimal.principal = "raju";

        System.out.println(Student.principal);

    }

}


10.  methodoverloading.java 


package com.tamilhacks;

public class MethodOverloading {

    public static void main(String[] args) {
        System.out.println("method overloading");
        add(2,5.5);
    }

    static void add(int num1 ){
        System.out.println(num1 + num1);
    }

    static void add(int num1 ,double num2){
        System.out.println(num1 + num2);
    }

    static void add(int num1 ,int num2, int num3){
        System.out.println(num1 + num2 + num3);
    }
}


11. methodoverride.java



package com.tamilhacks;

class a1{
    void display(){
        System.out.println(" al class");    }

}

class b1 extends a1{
    @Override
    void display(){
        System.out.println(" bl class");    }
    //child , sub has more power

}

public class Methodoverride {
    public static void main(String[] args) {
        System.out.println("method overriding");
        b1 obj = new b1();
        obj.display();

    }
}


12. main.java



package com.tamilhacks;

class s1{

    void s1m(){
        System.out.println("s1m");
    }

    class s2{
        void s2m(){
            System.out.println("s2m");
        }

    }

}

public class Main {

    public static void main(String[] args) {
        System.out.println("classes");

        s1 o = new s1();
        o.s1m();

        s1.s2 o1 = o.new s2();
        o1.s2m();



            }

    }


13. super.java 



package com.tamilhacks;

class a{ //super
    a(){
        System.out.println("a");
    }

    a(int i,int j){
        System.out.println("i , a");
    }
}

class b extends a {

    b(){
        System.out.println("b");
    }

    b(int i){
        super(i,i);
        System.out.println(" i b");
    }

}

public class Super {
    public static void main(String[] args) {
        System.out.println("super keyword");
        b obj = new b(10);

    }
}


14. this.java


package com.tamilhacks;

class Thiss{

    int number1;

    Thiss(int number1) {
        this.number1 = number1;
    }

}
 class This {

    public static void main(String[] args) {
        System.out.println("this keyword");
        Thiss object = new Thiss(100);
        System.out.println(object.number1);
    }

}


15. topic.java

package com.tamilhacks;


class Newclass {
    void useMe(){
        System.out.println("im use me method");
    }

    int sub(int a , int b){
        return a-b;
    }
}


public class Topic1 {
    public static void main(String[] args) {


        System.out.println("hi guys");
            methodOne(); //calling method
            System.out.println(methodTwo(20,3,5));  //arguments
            System.out.println(methodThree(2.5));

            Newclass object = new Newclass();
            object.useMe();
            int c = object.sub(10,5);
            System.out.println(c);

            int number = 10;
            String name = new String("karthik");
            // name.length();


        }

        private static void methodOne() {

            System.out.println("method 1");
        }

        static int methodTwo(int num1 , int num2 , int num3){  //parametrs
            return num1 - num2 * num3;
        }

        static double methodThree(double num1){

            return num1 * num1 ;
        }


    }

Comments

  1. Replies
    1. https://www.web2pdfconvert.com/

      Use this link and copy the tamlihacks link and paste in tha above link to download it as a pdf

      Delete

Post a Comment

Popular posts from this blog

Get Ethical Hacking Project #1

Thanks for your interest in our course This is a paid course, 150 rs for Indian people, 5$ for international people Instructions to get course: Indian people can get the course by paying using this UPI id   tamilhacks@ybl  (KARTHIKEYAN T) send 150 Rs to this upi id with subject bug bounty and after payment take a screenshot and send that to email id tamilhackstech@gmail.com - you will get the course within 24 hours. (there will be no tax, when paying using upi id)     The above mentioned method is most preferable. if you don't have a upi id app, install  phonepe  or  google pay   app and register there and pay easily  or  pay here using the alternate method to get this course, this link cost 18% gst for the course . (nearly 30-100 Rs for tax and other charges here )   After payment you will receive a payment confirmation mail along with a downlink for the course, you can download the course file using that . the course is in zip format, so after downloading the file extra

Learn c++ in Tamil | Complete guide and tutorial | Beginner to Advance all concepts explained.

hi guys welcome , all the coding used in video are available here : /* hi guys welcome to learn c++ in tamil what is C++ how what software your own program schools,clg,institute.... start 1.interest 2.patience 3.fun 4.practise computer program - app - programming source code - hardware - fb running , executing machine language :  101010 assembly lang : mov h1; high lang : c , c++....java , js , python  eg :  a+b .....1001010  compiler :  human to machine              machine to human  rules :  a+b;  usage:  games, manufacturing , embedded , finance , graphics , etc...  Guide: 1.problem 2.solution - alternative 3.program  - C++ 4.compile  - turboc , ide , codeblocks , cmd 5.result   - library file - linker : #include<iostream.h>    input , output std::cout<<"welcome";   standard character out << " "; primary section : 1.statements   ;  end 2.functions   main() 3.syntax  , syntax error pra

Get Bug Bounty Course

Thanks for your interest in our course Limited Offer This is a paid course, Rs 10000 ,Rs 1000  for Indian people, 75$ 15$ for international people , 50$ 10$ for Srilankan people Instructions to get course: Indian people can get the course by paying using this UPI id  tamilhacks@ybl  send 1000 Rs to this upi id with subject bug bounty and after payment take a screenshot and send that to email id tamilhackstech@gmail.com - you will get the course within 24 hours. (there will be no tax, when paying using upi id)    The above mentioned method is most preferable. if you don't have a upi id app, install phonepe or google pay   app and register there and pay easily  or  pay here using the alternate method to get this course, this link cost 18% gst for the course . (nearly 30-100Rs for tax and other charges here ) After payment you will receive a payment confirmation mail along with a downlink for the course, you can download the course file using that. As for international peopl