Educationkidda

Educationkidda

All subjects of coputer science available here

Breaking

Sunday, 24 November 2019

Autoboxing and unboxing in java with examples|Difference between them

November 24, 2019 0
Autoboxing and unboxing in java with examples|Difference between them

Boxing and unboxing:-

Boxing:-

     Boxing is the process  of the converting the primitive data typoe to the object of the coresponding
Wrapper class or assigning the value of the data types the object..

For  example :-
int a=10;
object obj;
obj=a;
Converting the int to the Integer.
Autoboxing and unboxing in java with examples|Difference between them
Autoboxing and unboxing in java with examples|Difference between them


Unboxing:-
   This the process of the assigning the value of the pobject into the primitive datatype or converting the corresponding Wrapper class into the primitive data types.

 See some information of Autoboxing and unboxing

Example1:-

class Demo1
{
public static void main(String args[])
{
Integer a=new Integer(12);
System.out.println(a);

int a1=10;
a=a1;//Auto boxing
System.out.println(a);

Boolean b1=new Boolean(true);
boolean b2=false;
b2=b1;//Unboxing
System.out.println(b1);

}
}


exapmle2:-

class Demo2
{
public static void main(String args[])
{
Boolean b=new Boolean("java");
if(b)//unboxing
{
System.out.println("s");
}
if(b=true)//Autoboxing
{
System.out.println("A");
}
}
}



Constructor in java and types of constructor with example in java|

November 24, 2019 0
Constructor in java and types of constructor with example in java|

Constructor in java

   Constructor is also know as the methid or the function in the java .Constructor are mainly used in the java programs to create  the object of the class.

Exmple:-

class Employee
  {
     public void setData()
        {
         System.out.println("This is the class Method");
    }
public static void main(String args[])
{
Employee e=new Employee();
e.setyData();
   }
}
Constructor in java and types of constructor with example in java|
Constructor in java and types of constructor with example in java|


           In this program we can clearly see that we have constructe the object of the Employee class  witn the hep of the new keyword.Normally cinstruction of the cklas means the allocating the memory space this reference.Refernce is the another topic we will disscuss deeply about this in another post. 


See some impoetant points  of the constructor

  1. The constructor is same like the fucntions or the methods used in the  progerams.
  2. constructor name should be same as the name of the class.
  3. The cionstructor having no return types 
  4. Constructors can use the  public access specifiers
  5. We can use the constructors  in the abstract class but can't instatiate using thid.But we can instatiate the concrete class.

Types of Constructors in java:-

There are two types of constructors in the java.

1.Default constructor
2.non parametrised constructor
3.parametrised constructors

Default constructor

  If we are not  defining any constructors in the program then at the time of construction of the object the default constructor will be  called.

Non parameterised constrcutors:-

  In the non parametirsed constructors we are not passing any arguments and the main point is that the at the time of the execution of the JVM call the non parameterised constructor.

Parameterised constructor:-

  It is the opposite of the non parameterised constrcutor.

See some xemple
Example1:-

    class Demo1
{
int data;
Demo1()
{
data++;
System.out.println("Object is constructed");
}
protected Demo1(int x)
{
data=x;
}
public static void main(String args[])
{
Demo1 dd=new Demo1();
Demo1 bb=new Demo1(12);

System.out.println("value of the first object is"+dd.data);
System.out.println("Value of the second object is"+bb.data);
}
}


Example2:-



class Demo2
{
int data;
Demo2()
{
data++;
System.out.println("the object is constructed");
}
public void increment()
{
data++;
}
public static void main(String arg[])
{
Demo2 dd=new Demo2();
dd.increment();
dd.increment();
dd.increment();
dd.increment();
dd.increment();
System.out.println("the data Value is"+dd.data);

}

}

 keep pratice this programs and try to get the out put.

next:-Use of this keyword(click here)








what is Command line arguments or cmd in java with exapmle

November 24, 2019 0
what is Command line arguments or cmd in java with exapmle

Command Line Arguments In Java:-

       Comand Line Argument means the passing the arguments through the main method.
Let's take example and then we can get more clarirty on that on that topic.
what is Command line arguments or cmd in java with exapmle
what is Command line arguments or cmd in java with exapmle

Exapmle:-

class CLA2
{
public  static void main(String args[])
{
call(args);
}
static void call(String  ss[])
{
int size=ss.length;
System.out.println("\nsee the elements of array");
for(int i=0;i<size;i++)
{
System.out.println(ss[i]);
}
}
}
    

    From this exmple i have shown that the how to take the inputs through the  command line argument.As we are using the various methods or various classess to take the input from the user like this through the command line argument we  can take the input from the user but here we d ont have to import any classess and we dont have to use  any methods.Here at the time of the programs execution  we take the input fro  the user from which we  can do various operation.

Take the another example for the command line argument

Example 2:--

class CLA 
{
public static void main(String args[])
{
System.out.println("Enter something ");
for(int i=0;i<args.length;i++)
{
System.out.println(args[i]);
}
}
}


     Here in this program at the time of programs execution or after  the compilation of the program we can take the  command line arguments.Here to know the size of the array or the command line argumnets we can use the "length" keyword .

Example 3:-

Here some  another example of the command Line Argument

 class CommandLineArgumentDemo
{
public static void main(String args[])
{
int a=0;
int b=args.length;
while(a++<b)
{
System.out.println(args[a]);
}
}
}

Example 4:-


class CommandLineArgumentOutSideMain 
{
public static void main(String args[])
{
call(args);
}
static void call(String ss[])
{
int size=ss.length;
System.out.println("See the command line argument.");
for(int i=0;i<size;i++)
{
System.out.println(ss[i]);
}
}
}

Pratice this programs on your computer we can get more clarity on this topic.My special suggesion is plz keep pratice all the java progarms beacuse it prety difficult to remember all the progarms we just have to keep some concept on your mind.So keep pratice and comment me if You are facing any problem in the code given.


Next--Constructos in java(click here)

Saturday, 23 November 2019

polymorphism in java and it's types in java|java Polymerphism programs

November 23, 2019 0
 polymorphism in java and it's types in java|java  Polymerphism programs

Polymorphism in java:-

        Polymorphis is feture of the java un wich the poly me ans many and merf means forms.In the polymorphism using one methd we can do various types of opeerations in different enviroments.

Types of Polymorphism:
There are two types of polymerphism in the java,
1.static polymephism
2.Dynamic polymerphism

what is polymorphism and it;s types in java|Polymerphism in java
what is polymorphism and it;s types in java|Polymerphism in java 

Static polymorphism:-

        In the static polymophism the method cans be overloaded that means we can use the same method with the different parameters and  different return type.It is also know as the early binding.
Exapmle of methiod overloading:-
In the Methidd overloading gthe metiod argume ts should be different from each other
like this:-

public void add(int a)
public int sum(int a,int b)

programs:-

class Methodoverloading
{
public void sertData(char a)
{
system.out.pierntln("c");
}
public int setData(char a,int num)
{
System.out.println("+c+"+num);
}

public sratic  void main(STring args[])
{
Methodoverloading md=new Methodoverloading();
md.setData(a);
md.setData(a,4);

}
}


Dynamic Polymorphism:-
    In the Dynamic polymerphism the methods can be overrided thats means the method should have the same name and same metod return type and the same arguments.The Method ovveride is possible only in case of the inhertance.It is also known as the late binding.

Exapmle of method Overriding:

class X
{
public void showMessage(String msg)
{
System.out.println("base calss Massage is:"+msg);
}
}
class Y extends X
{
@Override
public void showMessage(String s)
{
System.out.println("child class Message is"+s);
}
}
class Demo2
{
public static void main(String args[])
{
Y aa=new Y();
aa.showMessage("i am in the main");
}
}

Exapmle 2:-
class A
{
int data;
A()
{
increment();
}
public void increment()
{
data++;
}
}
class B extends A
{
B()
{
increment();
}
public void increment()
{
data+=10;
}
}
class Demo1
{
public static void main(String args[])
{
B bb=new B();
bb.increment();
System.out.println("data value is"+bb.data);
}
}


Differenece between the method overloading and method overriding





Method Overloading
Method overriding
1.This is the part of the polymorphism


2.This is alos known as late binding


3.Methoid name may not be same


4,Independed  on the inheritance


5.Arguments of the methods shoud not be same

1.This is alos the part of the polymorphism


2.This is alos known as early binding


3.Method name should be same


4.Without inheritance the method overriding is not possible

5.Arguments of the method should be same


Next-Dynamic Method dispatch in java(click here)









Sunday, 24 March 2019

Featues of java in details pdf core java

March 24, 2019 0
Featues of java in details pdf core java

Features of java:


Java is an object oriented programming language devloped by sun Microsystems of USA in 1991. J ava is hrst 'c s 

programming-languag'e which is not attached with hardware or operating sy stem. Program devloped in java can be exicuted anywhere and on any system.

Featurés of Java as follows:


1.Compiled and Interpreted ' .
2.Platform Independent and portable
3.objectioriented’ ' 
4.Robust and secure ' 
5.Distributed ‘ -
6.Familiar, §irnple . 
7.'Multithreaded and interactlve 
8.High performance 
9.Dynamic ensible extensible
Featues of java in details pdf core java
Featues of java in details pdf core java


Compiled and interpreted ;
Basically a computer language is either compiled or interpreted. Java comes together both these 

approch  thus making Java a two-stage system. java compiler translates Java code to Bytecode instructions and Java Interpreter generate machine code 

that can be directly executed by machine that is running the Java program. #1 5 


Platform Independent and portable :
Java supports the feature portability. Java programs can be easily moved from one computer system to 

another and anywhere. 0 Changes and upgrades in operating systems, processors and system resources Wih not force any 

alterationin Java programs. This is reason why Java, has become a trendy language for programmmg on Internet which interconnects different kind of systems worldwidw worldwide worldwide. 



Java certifies portability in two ways:
First way isJava compiler generates the bytecode and that can be executed on any machine. second way is, size of primitive data types are machine independent.

Objectoriented :
Java is truly object-oriented language. In Java, almost everything is an Object. All program code and data exist in objects and classes. I 

Java comes with an extensive set of classes; organize in packages that can be used  in program by Inheritance. the object model in Java is trouble-free and easy to enlarge. 

Robust and secure o Java is a most strong language which provides many securities to make certain reliable code.

Java also includes the concept of exception handling, which detain serious error and reduces all kind  of threat of crashing the system. nous em) 

Security is an important feature of Java and this is the strong reason that programmer use for programming on Internet. 

The absence of pointers in Java ensures that programs cannot get right of entry  to memory location without proper approval. 

Distributed . .
Java is called as Distnbtited language for construct applications 0n network which can contribute both data and program. Java applications can open and access remote objects on internet easily.that means multiple prigram at multiple remote location to work together on a single task

Simple and small :
Java is very small and Simple language, 

Java does not use pointer and header files goto statements etc. It eliminates operator overloading and multiple inheritance.

Multithreaded and Interactive .:

Multimreaded means managing multiple task simultaneously. Java maintains multithreaded programs: That means we need not wait for the application to complete one task before starting next task. This feature is helpful for graphic applications. 
High performance :

Java performance is very extraordinary for an interpreted language, majorly due to the use of in' mediate byteeode. Java architechture s is also designed to reduce overheads during runtime. The incoporatio  multithreading improves the execution  speed of program. 

Dynamic and Extensible:
java is also dynamic language.

java is capable od dynamically linking in new class, libraries, methods and objects. 

java can also establish the type of class through the query building . 

It is‘ possible to either dynamically link or abort the program, depending on the reply. 

Java program is support functions written in other language such as C and C++ know as native methods.
kn known a native.

Next:Data type of java