Skip to main content

Posts

Packages In Java

Recent posts

Interface In Java

 An Interface  in java programming language is exact copy of a class. It consist of abstract methods and static constants.  Interface is a method which is used to achieve abstraction. It contains abstract methods not the method body. It is used to achieve abstraction and multiple inheritance in java. It represents the IS-A relationship.   Reasons why to use Inheritance in java? 1) It is used to achieve abstraction. 2) By interface, we can support the functionality of multiple inheritance. 3) It can be used to achieve loose coupling.( loose coupling in java means that the classes are independent of each other. The only knowledge one class has about the other class is what the other class has exposed through its interface in loose coupling.). Declaration of an Interface in Java Interface in java is declared using the keyword that is interface keyword.  It provides that total abstraction, that means all methods in the interface are declared with empty body and all the fields are public, s

Inheritance In Java

  Inheritance Inheritance is a process or a mechanism where one class acquire the properties which include methods and fields of another class. With the use of this concept the information is made manageable in a hierarchical order. The class which inherits the properties of another class is known as subclass  or derived class or child class . and the class whose properties are inherited is called as base class or parent class . In java inheritance cannot be achieved until we use extends keyword. Reason to use Inheritance 1 For Method overriding 2 For code reusability  Syntax: class abc { ......... ......... } class xyz extends abc { ......... ......... } ---------------------------------------------------------------------------------------------------------------------------- Example //WAP to Demonstrate Inheritance............. import java.io.*; class Superclass { BufferedReader r=new BufferedReader(new InputStreamReader(System.in)); Double num1,num2; void get() { try

String in Java

 Topics to be covered... 1) String in Java 2)  string literal,new keyword in java 3) string array in java 4)  What is mutable string ? 5) Java StringBuffer class | StringBuffered methods() 6) reverse a string in java | how to reverse a string in java | string reverse in Java 7) string program in java --------------------------------------------------------------------------------------------------------------------------- *1)String:- string is generally a sequence of characters, but in java programming language string it is a sequence is an object which represents the sequence of the characters. -------------------------------------------------------------------------------------------------------------------------------- *2)string literal and new keyword:- string literal in java is created by using double quotes " ", let's assume an example String s=" Welcom to Programming Worlds and Facts..";   now let's see how to allocate string new keyword  String s1=&

Java - Static variable, static method and static block with example.

Java Static keyword, Static method and Static block........ Questions.......?? 1) What is static keyword , static method() , static block 2) Define static keyword , static method() , static block 3) What do you mean by static keyword , static method() , static block 4)static keyword , static method() , static block in Java ?     1)Static Keyword:- Static keyword in Java Programming language is used for memory management purpose, it indicates that a particular member belong to a type itself, rather than to an instance of that type. As we mentioned above that is used for memory management purpose it means that static keyword gets memory once in the class which help in reduction of the memory, which makes the execution speed of the program fast which is a great advantage of the static keyword. let's take example how static keyword works..... firstly we will see how memory get wasted when we didn't use the static keyword. class company {  int emp_id; 

Java this keyword

  this keyword in Java programming language is a reference variable that refers to the current object. this in Java is  a reference to the current object, whose method is being called upon. You can use this keyword to avoid naming conflicts in the method/constructor of your object. What are the usages of this keyword in Java Programming Language . 1) this can be used to refer the current class instance variable. 2) this can be used to invoke current class method. 3) this() method ca be used to invoke current class constructor. 4) this can be passed as an arguments in the method call. 5) this can be passed as an arguments in the constructor call. 6) this can be used to return the current instance from the method. Lets see an example to understand how actually this keyword works.. class student { int roll_no;  //  variable declaration  String Student_name; // variable declaration float fees; //variable declaration student(int roll_no, String Student_name, float fees) // parameter

What is Procedural Programming Language(PPL)

  Procedural Programming Language. Procedural Programming might be the primary programming worldview that another engineer will learn. Essentially, the procedural code is the one that straightforwardly trains a gadget on the best way to complete an errand in consistent advances. This worldview utilizes a direct top-down methodology and treats information and techniques as two distinct elements. In view of the idea of a methodology call, Procedural Programming isolates the program into strategies, which are otherwise called schedules or capacities, just containing a progression of steps to be done.  Basically, Procedural Programming includes recording a rundown of directions to mention to the PC what it ought to do bit by bit to complete the job needing to be done.  Key Highlights of Procedural Programming  The vital highlights of procedural writing computer programs are given underneath:  1)Predefined capacities: A predefined work is normally a guidance distinguished by a name. For the