Showing posts with label Core Java. Show all posts
Showing posts with label Core Java. Show all posts

Control Statements

In java there are two types of Statements. They are:
  • Sequential Statements (statements which are executed one by one.)
  • Control Statements (Statements which are executed repeatedly and randomly)
When we come to control statements, these are again divided into 3. they are:
  • Conditional or Decision Making statements(if-then, if-then-else, switch)
  • Looping Statements(for, while, do-while)
  • Branching Statements(break, continue, return)

Abstract Classes

      An Abstract class is the one that consists of both abstract as well as concrete methods. Even if a class have only one abstract method, we declare that class as abstract class. The following is the example of abstract class.

Abstract Class Example
Fig1: Abstract Class Example

Interfaces

         An Interface is one which contains the set of abstract methods, or Interface is similar to class which contains the set of variables and methods. Interfaces are declared using the interface keyword, and may only contain method signature and constant variable declaration. An interface may never contain method definition. 

Inheritance

      The process of acquiring the members of one class to another class is called as Inheritance or Deriving the new class form the old class or the existing class is called as Inheritance. In this concept the derived class acquires all the features of the old/existing class from which it is derived. This inheritance is achieved in the java programming by the usage of extend keyword. Suppose when classA is inherited from classB, then classA is called as subclass and classB is called as super class/parent class. classA gets the copy of classB,which provides all its features. The following is a syntax to extend a class.
  • public class <class_name1> extends <class_name2>

Types of Methods

A Method is a set of instructions that solve a particular task. There are majorly 3 types of methods in java, They are:
  1. Instance Methods
  2. Static Methods
  3. Recursive Methods

Class and Object

CLASS:

CLASS is a specification of variables and methods where the variables are used for storing the data and methods are used for performing the operations. A class is a collections of objects. Class does not exit physically in the real world. A class can be considered as a user defined data type. Class is an example of Encapsultion. The following is the syntax of class:

OOPS Concepts

There are two types of programming languages through which we develop our applications. These two languages are based on two different concepts, they are: 
  1. Procedure Oriented Concepts
  2. Object Oriented Concepts

Procedure Oriented Concepts:

           The applications that are developed using procedure oriented concepts are based on procedures or functions. The language that follows procedure oriented concepts is called Procedure Oriented Language. These languages are also called as Structured Programming Language.

JVM Architecture

JVM is a program that converts Bytecode instructions into Machine code. The following figure shows the JVM architecture:

JVM Architecture
Fig: JVM Architecture

API

What is API?


An API is an acronym for Application Programming Interface. API is a document but not the software. API consists of specifications. An API document can be in any format ie.., .doc, .pdf, .html, .txt etc..., There are two types of API, they are:

Difference between String and StringBuffer/StringBuilder

       The difference between String and StringBuffer/StringBuilder is that String object is immutable(the value cannot be changed), where as StringBuffer/StringBuilder objects are mutable(value can be changed). Then the next question that comes to our mind is “If String is immutable then how can we able to change the contents of the object?” . Well, when we change the value of the string, it’s not the same String object that reflects the changes you do. Internally a new String object is created to do the changes. So suppose you declare a String object:

Comments and Variables

 Sun Microsystems have divided Java into 3 parts-Java SE(Standard Edition), Java EE(Enterprize Editon), and Java ME(Micro Edition). We are studying Java SE.

Lets start with Comments

Comments:  

            Writing comments is a good programming habit. Comments are description about the features of a program. This means that whatever we write in a program should be described using comments. This comments make the program more understandable.  
   There are 3 types of comments: 

Java Threads

SINGLE TASKING:

        Executing one task at a time is called Single Tasking. Processor executes only one program at a time. The remaining programs should wait until the first program completes. So, here in this single tasking, much amount of time is wasted.

Static Variables Methods and Blocks

           You may be familiar with the static keyword. Let us see what is static keyword and where it is used. First let us know about static variables and then followed by methods and blocks.
Static Variables: The variables whose values are unchanged until the end of the class are called Static Variables. These variables are also called as Class Variables. The memory for this variables is allocated before the object is created. These variables are accessed using the class name.  
Static Methods: These are the methods whose names are prefixed with static keyword. These are accessed by using the class name. The following is the syntax for calling a static method. 

Java Introduction

Java was invented by James Gosling and his team. This language was developed by the company Sun Micro Systems. Initially the language was called as Oak, but since the Oak was already registered they have changed the name to JAVA.

Java is the highly using programming language. When Java Team were asked to say why that programming language was given the name "JAVA"? They replayed as follows. 
     The name was chosen during one of several brainstorming sessions held by the Java software team. We were aiming to come up with a name that evoked the essence of the technology -- liveliness, animation, speed, interactivity, and more. "Java" was chosen from among many, many suggestions. The name is not an acronym, but rather a reminder of that hot, aromatic stuff of coffee that many programmers like to drink lots of.