A blog for computer science passionates.

Thursday, 20 February 2020

Hello Friends!!!
Today we are going to learn the example of datatypes. Please refer to Datatypes to get all the details of Java Datatypes.

Let's start with What is variable?
Variable (scalar) is a named memory location (Name given by a programmer or developer to identify that memory location for their purpose is also known as Identifier) we can store a value to a variable it is temporary storage for a value.

In Java, we can define a variable with its type. Here is how to declare a variable?
<data_type> <var1>,<var2>,<var3>;

For Example,
int employee_id, length;

Even we can assign a value to the variable such as,
<data_type> <var1>=<val1>,<var2>=<val2>;

For Example,
int employee_id=123,length=5;

Now let's take a demo class to define a variable with different data types.

Here is the output of the above example,
Fig. The output of the above example
This is the simple example of data types, that shows how to define variables with different data types and how to assign values and how to access values from the variable.

Here, in long and float data type we need to add L or l or F or f after values so that values can be considered as long or float otherwise it is considered as integer or double value.
In float datatype, if we don't write f or F, it shows an error.
float f1=45.567;    //if we write this line, it generates below error.
 
Fig. An Error for float data type
This is an example of Data Tyes of Java. In the next article, we will learn something new in Java.
Till then that's it, Happy Coding...☺😊

Sunday, 16 February 2020

Hello Friends!!!

This is the third algorithm, here I am going to share the support vector machine one more classification algorithm there are more classification algorithms I recommend you to refer these articles Logistic Regression and Naive Bayes classifiers to get proper ideas about classification algorithms.

SVM is really a very simple algorithm that works more accurately with less computational work. Actually, the support vector machine is a model works on a supervised learning technique, it works on both regression and classification. And generally suitable for binary classification. SVM is used to separate N - Dim hyperplane. For Example, if we have labeled data such as an image is a cat or not a cat. Here, we have two different labels Cat and Not and SVM Separates these labels on a hyperplane.
Fig. SVM Separates Labels


The above figure shows that the SVM separates the 2D hyperplane. In the above example, we have two labels blue dots represent Cat label and the orange triangle represents Not a Cat label. And in the above figure, one can see the separation of two different labels.

So, That's it you can get easily what is the meaning of Support Vector Machine? In the next article, we will learn more about SVM.

Tuesday, 11 February 2020

Hello Friends!!!

In this article, we are going to learn different data types in Java. Java is a strongly (Strict) typed programming language. i.e. all the variables or expressions must have data types as Java compiler checks whether the variable or expression is compatible with data or not. There are two different types:
  • Primitive
  • Non - Primitive
Primitive Data Types: In simple words, primitive data types mean primary data types, as we all know that we have different data such as numeric data or a character type of data based on the types of data Java defines different data types. such as integer, float, long, short, byte, double, character and boolean.

Non-Primitive Data Types: These data types works on arrays, string or class or interfaces, etc. generally, non-primitive datatypes made with primary (primitive) data types.


Data type
Range
Size (Bits)
Group
byte
–128 to 127
8
Integer
short
–32,768 to 32,767
16
Integer
int
–2,147,483,648 to 2,147,483,647
32
Integer
long
–9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
64
Integer
float
1.4e–045 to 3.4e+038 (Approx)
32
Floating Point
double
4.9e–324 to 1.8e+308 (Approx)
64
Floating point
char
0 to 65,536
(\u0000 to \uFFFF)
16
Character
boolean
true / false
1
Boolean


Table.1 Primitive Datatypes

Java supports eight different primary data types with four different groups as you can see in the table. In the next article, we will learn more about data types i.e. how to work on these data types? till then enjoy Java and start with Hello World Coding.
Happy Coding...☺

Wednesday, 29 January 2020

Hello Friends!!!!

In this article, I am going to share one big thing i.e. Say Hello World i.e. How to start Java programming. Let's start.

I give you one suggestion before the start, if you are a beginner in programming please use notepad as an editor don't use any smart editor for Java or any other development. For Java, Netbeans and Eclipse both are smart editors but don't use it if you are a beginner otherwise you don't feel Java programming and work hard and tough so we can remember syntaxes and can learn more effectively.

Let's start Java Programming. Our First Program is to say Hello World, Hello Java!!!

So for that open notepad (I am working on Windows) or open run (window+r) and type notepad press enter.

It will open notepad now type below program:


And you just need to run this code in the command prompt: To open a command prompt again go to the run (window+r) and type cmd and press enter or click OK button.

Now you need to open your path i.e. your drive and directory. Just follow the following commands

To open drive in cmd:
type drive letter and colon i.e. if you want to open d drive, type d: command.
And you will get your drive open with

d:\>

To open directory (folder) that should be available in your drive use below command:

cd <your_directory_name>\<another directory name (if any)>

For Example, in d drive, we have java folder in which ch1 folder so type

This command opens all directories in one command
d:\> cd java\ch1

or
This command opens directory one by one.
d:\> cd java
d:\java> cd ch1

it will open d:\java\ch1> directory.Check out this video on how to open drive and directory in cmd. (I show two different ways to open directory either one by one or in a hierarchy)

To Compile & Run Java Program:

We have javac command to compile the program and java command to run the program.

For example, in our above example we define a class with the name SayHello now we just save this file with the name "SayHello.java" and just compile this file with the following command:


javac SayHello.java
This command generates a class file and  we need to run this class file by using the following command:


java SayHello

This command shows the output "Hello World, Hello Java!!!" See the figure below:
Fig. The output of the Java program

So, that's it for today in the next article I will tell you about what we exactly use i.e. which classes and what is the main method and some other aspects.

Till then Happy Coding☺

Monday, 27 January 2020

Hello Friends!!!
Let's discuss some concepts of 😊bject-☺riented Programming. First of all,
What is Object?
  • In simple words, the object is a combination of Data and Functions. It represents a class and class contains data and functions (methods). For example, consider a class of Animals and an object of an animal class is a dog, cat, etc. it has data i.e. a dog has four legs, two eyes and function i.e. the behavior of a dog is barking.
What is the Class?
  • The class is from which object belongs, i.e. in our above example if an object is a dog, it comes from Animal class. Even we can say that the class is a collection of Data and Function and to represent the data and function we need to make an object. 
What are Methods?
  •  The methods, to work on data, manage data and operate these data. For example, if we have the data about the employee of a company such as employee id, name salary and based on that salary want to calculate allowance and total salary of an employee one needs to define a method.
These three are the main pillars of object-oriented programming. Let's discuss more topics about it...

Inheritance: 
As we know that object-oriented programming is based on real-world concepts and in the real world we have different relations. so object-oriented programming also believes in the relationship. So we have this concept of inheritance. In which, we have more than one class and we relate these classes with each other and reuse the attributes. Reusability is the key for OOP. There are different types of inheritance such as,
  • Single-Level
  • Multi-Level
  • Hierarchical
  • Multiple
  • Hybrid
  • Multipath
But, Multiple and Multipath inheritances do not support by Java. As Java works on real world concept and in real world multiple parents are not possible on child or children, in multiple and multipath inheritance work on multiple parent so.
I just want to figure out all the types of inheritance. And it is easy to get.

Fig. Types of Inheritance
Polymorphism:
It is a greek word means Multiple forms of an attribute such as methods or constructor. To build method or constructor in a class with multiple forms we have to follow some rules,
  • Pass different numbers of arguments in a method or constructor.
  • In a method, we can set a different return type of a method.
For example,
int area(int length, int breadth)
double area(int radius)

This is called Method Overloading.
In inheritance, we can achieve Method Overriding. In inheritance, we have two classes parent and child class, in parent class we have one method and we redefine that method with the same syntax is called method overriding.

Abstraction and Encapsulation:
Through abstraction, we can show all the essential elements and in encapsulation, we can hide the necessary data.

We will see all the concepts in detail when we will look at examples, through all these concepts you feel that Java is based on Real-World thus Java is really great and powerful because it works with and on data.
While working with any object-oriented programming we need to think only one thing and it is data.

Hope you enjoy, this and feel these concepts are yours and related to our life somewhere :)

Sunday, 5 January 2020

Hello Friends!!! and welcome again,
Happy new year to all Hope you enjoyed, this is the first post of this year...
In this article, we are going to discuss more features of Java. If you do not look at the first part, please read it first. Now, Let's move to the remaining features of Java,
  • Secure: Java is secure, as it is interpreted and compiled even it doesn't work directly with memory. It has JVM, so Java is a secure programming language.
  • Portable: The main problem with any programming is portability. And Java is designed to work with 
    WORA "Write Once, Run Anywhere"
    rule and JVM is the main part to provide portability. So, our Java Application runs today, tomorrow and F☺rever.
  • Multithreaded: Java is a multithreaded programming language. In our application, there are lots of different tasks, that we need to manage simultaneously. So, Java works with the threading mechanism and our application can manage multiple threads at the same time even we can synchronize it.
  • Interpreted and High Performance: As we have discussed earlier, Java is interpreted programming language. It interprets in JVM and generates a byte code and uses JIT (Just - in - time) compiler to achieve high performance.
  • Distributed: Java can work with distributed environment also, it has RMI (Remote Method Invocation) API to work on a distributed environment.
  • Dynamic: Java programs have run-time type information to validate and verify the access of objects at run-time to make code type-safe.
 So, These are the different features, after seeing all the features we can get that Java has rich set of features and How Java becomes powerful?
In the next article, we will learn more about Java Programming Language.

Monday, 9 December 2019

Hello Friends!!!

In this article, we are going to start Java Programming. There are lots' of things that are there in Java, first of all, we know about Java is a programming language. it is an Object-Oriented Programming Language. And we also know about different Concepts of Object-Oriented Programming languages such as class, object, abstraction, encapsulation, inheritance, polymorphism, etc. (If you don't know the concepts don't worry we will discuss all the things when we will look at the examples)

So, Lets' start with features (Characteristics) of Java:
There are lots' of different features of Java and through that Java becomes a powerful and most used programming language. Let's start
  • Platform Independent
  • Object-oriented
  • Simple
  • Secure
  • Portable
  • Robust
  • Multithreaded
  • Interpreted
  • High Performance
  • Distributed
  • Dynamic
See, the rich list of features, Let's start with
  • Platform Independent: Java is an Open source and platform-independent programming language. The team James Gossling design and develop this language with the goal of platform independence. The program written in Java executes on virtual machine i.e. JVM and JVM is available on different platforms. So Java becomes platform-independent.
  • Object-Oriented: Java is an Object Oriented Programming language, like C++. Some object-oriented features of C++ inherited by Java. As Java is an OOP, an object is the key or core part of Java, everything in Java depends on the Object to manage data and perform different operations by using methods.
  • Simple: Java is simple, as it is inherited from C and C++. If you are familiar with C and/or C++ programming, it will become easy to work with Java programming. 
  • Robust: Java is robust as it works on different platforms. The main benefit of the strictness of Java is it reduces the number of errors as it is strictly typed language and it checks error compile time as well as runtime also.
As we know that Java has a rich set of characteristics thus Java becomes most popular in this article I cannot add all the features so in the next part we will learn all the remaining features of Java.

That's it for this article, Have a Happy Coding and programming in Java...☺😊