What Is Java? Java is an object-oriented programming language developed by Sun Microsystems, a company best known for its high-end Un...
What Is Java?
Java is an object-oriented programming language developed by Sun Microsystems, a company
best known for its high-end Unix workstations. Modeled after C++, the Java language was
designed to be small, simple, and portable across platforms and operating systems, both at the
source and at the binary level.
Advantageous of JAVA
- Java Is Platform-Independent
Platform-independence is a program’s capability of moving easily from one computer system to another.Platform independence is one of the most significant advantages that Java has over other programming languages, particularly for systems that need to work on many different platforms.Java is platform-independent at both the source and the binary level.
- Java Is Object-Oriented
Java’s object-oriented concepts are inherited from C++, the language on which it is
based, but it borrows many concepts from other object-oriented languages as well. Like most
object-oriented programming languages, Java includes a set of class libraries that provide basic
data types, system input and output capabilities, and other utility functions. These basic classes
are part of the Java development kit, which also has classes to support networking, common
Internet protocols, and user interface toolkit functions.
- Java Is Easy to Learn
In addition to its portability and object-orientation, one of Java’s initial design goals was to be
small and simple, and therefore easier to write, easier to compile, easier to debug, and, best of
all, easy to learn.
Java is modeled after C and C++, and much of the syntax and object-oriented structure is
borrowed from the latter. If you are familiar with C++, learning Java will be particularly easy for
you, because you have most of the foundation already.
Platform-independence is a program’s capability of moving easily from one computer system to another.Platform independence is one of the most significant advantages that Java has over other programming languages, particularly for systems that need to work on many different platforms.Java is platform-independent at both the source and the binary level.
Java’s object-oriented concepts are inherited from C++, the language on which it is based, but it borrows many concepts from other object-oriented languages as well. Like most object-oriented programming languages, Java includes a set of class libraries that provide basic data types, system input and output capabilities, and other utility functions. These basic classes are part of the Java development kit, which also has classes to support networking, common Internet protocols, and user interface toolkit functions.
In addition to its portability and object-orientation, one of Java’s initial design goals was to be small and simple, and therefore easier to write, easier to compile, easier to debug, and, best of all, easy to learn. Java is modeled after C and C++, and much of the syntax and object-oriented structure is borrowed from the latter. If you are familiar with C++, learning Java will be particularly easy for you, because you have most of the foundation already.
Here is some simple java programs check this out:
1)mycircle.java
class circle
{
public double area(int a)
{
return (3.14*a*a);
}
}
public class mycircle extends circle
{
public int r;
mycircle(int a)
{
r=a;
}
public double cirf()
{
return(3.14*r*2);
}
public static void main(String[] args)
{
double obarea,obcirf;
int b;
mycircle cobj = new mycircle(3);
b=cobj.r;
obarea=cobj.area(b);
obcirf=cobj.cirf();
System.out.println("Area="+obarea);
System.out.println("Circumference="+obcirf);
}
}
2)Program to implement method and constructor overloading
import java.lang.*;
class over
{
public int x,y;
public String str1,str2;
public over()
{
x=15;
y=25;
str1="first";
str2="second";
}
public over(int a,int b)
{
x=a;
y=b;
}
public over(String a,String b)
{
str1=a;
str2=b;
}
public int greater(int a,int b)
{
if(a>b)
return a;
else
return b;
}
public String greater(String a,String b)
{
if(a.compareTo(b)>0)
return a;
else
return b;
}
}
class overload
{
public static void main(String args[])
{
int m,n;
String a1,b1;
m=Integer.parseInt(args[0]);
n=Integer.parseInt(args[1]);
a1=args[2];
b1=args[3];
over ob1=new over(m,n);
over ob2=new over(a1,b1);
System.out.println("Largest of "+m+","+n+" is "+ob1.greater(m,n));
System.out.println("Largest of "+a1+","+b1+" is "+ob1.greater(a1,b1));
}
}
3)Prime.java
import java.lang.*;
public class Prime
{
public static void main(String[] args)
{
int n = Integer.parseInt(args[0]),flag;
System.out.println("Generate Prime numbers between 1 and " + n);
for (int i = 1; i<n; i++)
{
flag=0;
for (int j = 2; j < i; j++)
{
if (i % j == 0)
{
flag=1;
break;
}
}
if(flag==0)
System.out.print(" "+i);
}
}
}
Binary Formats
The complement to the textual format is the binary format, which is sometimes necessary to use
for efficiency purposes, or because there’s just no useful way to represent data in a textual manner.
Also, with numeric data, one can often lose precision when converting to and from a textual format,
so it’s better to stick with a binary format.
The key functions for converting R objects into a binary format are save(), save.image(), and
serialize(). Individual R objects can be saved to a file using the save() function.
> a <- data.frame(x = rnorm(100), y = runif(100))
> b <- c(3, 4.4, 1 / 3)
>
> ## Save 'a' and 'b' to a file
> save(a, b, file = "mydata.rda")
>
> ## Load 'a' and 'b' into your workspace
> load("mydata.rda")
If you have a lot of objects that you want to save to a file, you can save all objects in your workspace
using the save.image() function.
> ## Save everything to a file
> save.image(file = "mydata.RData")
>
> ## load all objects in this file
> load("mydata.RData")
Notice that I’ve used the .rda extension when using save() and the .RData extension when using
save.image(). This is just my personal preference; you can use whatever file extension you want.
The save() and save.image() functions do not care. However, .rda and .RData are fairly common
extensions and you may want to use them because they are recognized by other software.
The serialize() function is used to convert individual R objects into a binary format that can be
communicated across an arbitrary connection. This may get sent to a file, but it could get sent over
a network or other connection.
When you call serialize() on an R object, the output will be a raw vector coded in hexadecimal
format.
Types of random variables
So far, we are dealing with discrete random variables. These are variables whose range is
finite or countable. In particular, it means that their values can be listed, or arranged in a
sequence. Examples include the number of jobs submitted to a printer, the number of errors,
the number of error-free modules, the number of failed components, and so on. Discrete
variables don’t have to be integers. For example, the proportion of defective components in
a lot of 100 can be 0, 1/100, 2/100, ..., 99/100, or 1. This variable assumes 101 different
values, so it is discrete, although not an integer.
On the contrary, continuous random variables assume a whole interval of values. This
could be a bounded interval (a, b), or an unbounded interval such as (a,+∞), (−∞, b), or
(−∞,+∞). Sometimes, it may be a union of several such intervals. Intervals are uncountable,
therefore, all values of a random variable cannot be listed in this case. Examples of
continuous variables include various times (software installation time, code execution time,
connection time, waiting time, lifetime), also physical variables like weight, height, voltage,
temperature, distance, the number of miles per gallon, etc. We shall discuss continuous
random variables in detailed.
For comparison, observe that a long jump is formally a continuous random
variable because an athlete can jump any distance within some range. Results of a high
jump, however, are discrete because the bar can only be placed on a finite number of
heights. ♦
Notice that rounding a continuous random variable, say, to the nearest integer makes it
discrete.
he definition of Cloud Computing, as provided by National Institute of Standards and Technology (NIST), per work [1] is, ”A model for enabling ubiquitous, convenient, on demand network access to a shared pool of configurable computing resources (e.g. Networks, Servers, Storage, application and services) that can be rapidly provisioned and released with minimal management effort or the service provider interaction”. The majority of cloud computing infrastructure currently consists of reliable services delivered from datacenter which is built on servers with different levels of virtualization technologies. Many companies provide the cloud computing platform such as Amazon, Microsoft, Google, Rackspace, IBM, VMware etc. Cloud computing system provides the service to the user and is characterized by high scalability, portability, elasticity and reliability. The resources of the cloud computing system are transparent to the application and the user does not know the location or configuration or capacity details of the resources. The users can access data and applications from anywhere through internet which means great portability. A major challenge in cloud computing is scheduling that is to allocate tasks to available resources on the basis of task qualities, metrics and requirements without affecting the services provided by the cloud. Scheduling in cloud computing system decides how to allocate the resources such as CPU, memory, secondary storage space, I/O, network bandwidth etc. between users and tasks. A good scheduler adapts its scheduling strategy according to the changing environment over time, the nature of tasks and relative metrics of the tasks involved in batch of tasks submitted for processing. Scheduling refers to the set of policies to control the order of work to be performed by a computing system. There are various types of scheduling algorithms existing in distributed computing system, and job scheduling is one of them. The main advantage of job scheduling algorithm is to achieve a high performance computing and the best system throughput. Scheduling manages availability of resources like CPU, memory and good scheduling policy gives maximum utilization of resources. Virtual Machine (VM) is a process of mapping virtual machines to Physical Machines. As Virtualization is a core technology of cloud computing, allocation of Virtual Machines has become important challenge in cloud computing. Several research works addressed the importance of placing VMs appropriately. Recently in works [2] and [3] two stage scheduling model is designed and developed for allocation of resources in cloud to the incoming jobs in the form of Virtual machines. Load balancing affects cloud computing and improves the performance by re-distributing the load among the computing resources. Jobs are transferred from one node to another through the network. Little work is reported till date regarding cloud scheduling with load balancing strategy. Hence in this paper we designed and developed a novel efficient cloud scheduling algorithm based on load balancing analytics for allocation of physical resources in the form of virtual machine to incoming job requests.
1)mycircle.java
class circle
{
public double area(int a)
{
return (3.14*a*a);
}
}
public class mycircle extends circle
{
public int r;
mycircle(int a)
{
r=a;
}
public double cirf()
{
return(3.14*r*2);
}
public static void main(String[] args)
{
double obarea,obcirf;
int b;
mycircle cobj = new mycircle(3);
b=cobj.r;
obarea=cobj.area(b);
obcirf=cobj.cirf();
System.out.println("Area="+obarea);
System.out.println("Circumference="+obcirf);
}
}
2)Program to implement method and constructor overloading
import java.lang.*;
class over
{
public int x,y;
public String str1,str2;
public over()
{
x=15;
y=25;
str1="first";
str2="second";
}
public over(int a,int b)
{
x=a;
y=b;
}
public over(String a,String b)
{
str1=a;
str2=b;
}
public int greater(int a,int b)
{
if(a>b)
return a;
else
return b;
}
public String greater(String a,String b)
{
if(a.compareTo(b)>0)
return a;
else
return b;
}
}
class overload
{
public static void main(String args[])
{
int m,n;
String a1,b1;
m=Integer.parseInt(args[0]);
n=Integer.parseInt(args[1]);
a1=args[2];
b1=args[3];
over ob1=new over(m,n);
over ob2=new over(a1,b1);
System.out.println("Largest of "+m+","+n+" is "+ob1.greater(m,n));
System.out.println("Largest of "+a1+","+b1+" is "+ob1.greater(a1,b1));
}
}
3)Prime.java
import java.lang.*;
public class Prime
{
public static void main(String[] args)
{
int n = Integer.parseInt(args[0]),flag;
System.out.println("Generate Prime numbers between 1 and " + n);
for (int i = 1; i<n; i++)
{
flag=0;
for (int j = 2; j < i; j++)
{
if (i % j == 0)
{
flag=1;
break;
}
}
if(flag==0)
System.out.print(" "+i);
}
}
}
Binary Formats
The complement to the textual format is the binary format, which is sometimes necessary to use
for efficiency purposes, or because there’s just no useful way to represent data in a textual manner.
Also, with numeric data, one can often lose precision when converting to and from a textual format,
so it’s better to stick with a binary format.
The key functions for converting R objects into a binary format are save(), save.image(), and
serialize(). Individual R objects can be saved to a file using the save() function.
> a <- data.frame(x = rnorm(100), y = runif(100))
> b <- c(3, 4.4, 1 / 3)
>
> ## Save 'a' and 'b' to a file
> save(a, b, file = "mydata.rda")
>
> ## Load 'a' and 'b' into your workspace
> load("mydata.rda")
If you have a lot of objects that you want to save to a file, you can save all objects in your workspace
using the save.image() function.
> ## Save everything to a file
> save.image(file = "mydata.RData")
>
> ## load all objects in this file
> load("mydata.RData")
Notice that I’ve used the .rda extension when using save() and the .RData extension when using
save.image(). This is just my personal preference; you can use whatever file extension you want.
The save() and save.image() functions do not care. However, .rda and .RData are fairly common
extensions and you may want to use them because they are recognized by other software.
The serialize() function is used to convert individual R objects into a binary format that can be
communicated across an arbitrary connection. This may get sent to a file, but it could get sent over
a network or other connection.
When you call serialize() on an R object, the output will be a raw vector coded in hexadecimal
format.
Types of random variables
So far, we are dealing with discrete random variables. These are variables whose range is
finite or countable. In particular, it means that their values can be listed, or arranged in a
sequence. Examples include the number of jobs submitted to a printer, the number of errors,
the number of error-free modules, the number of failed components, and so on. Discrete
variables don’t have to be integers. For example, the proportion of defective components in
a lot of 100 can be 0, 1/100, 2/100, ..., 99/100, or 1. This variable assumes 101 different
values, so it is discrete, although not an integer.
On the contrary, continuous random variables assume a whole interval of values. This
could be a bounded interval (a, b), or an unbounded interval such as (a,+∞), (−∞, b), or
(−∞,+∞). Sometimes, it may be a union of several such intervals. Intervals are uncountable,
therefore, all values of a random variable cannot be listed in this case. Examples of
continuous variables include various times (software installation time, code execution time,
connection time, waiting time, lifetime), also physical variables like weight, height, voltage,
temperature, distance, the number of miles per gallon, etc. We shall discuss continuous
random variables in detailed.
For comparison, observe that a long jump is formally a continuous random
variable because an athlete can jump any distance within some range. Results of a high
jump, however, are discrete because the bar can only be placed on a finite number of
heights. ♦
Notice that rounding a continuous random variable, say, to the nearest integer makes it
discrete.
he definition of Cloud Computing, as provided by National Institute of Standards and Technology (NIST), per work [1] is, ”A model for enabling ubiquitous, convenient, on demand network access to a shared pool of configurable computing resources (e.g. Networks, Servers, Storage, application and services) that can be rapidly provisioned and released with minimal management effort or the service provider interaction”. The majority of cloud computing infrastructure currently consists of reliable services delivered from datacenter which is built on servers with different levels of virtualization technologies. Many companies provide the cloud computing platform such as Amazon, Microsoft, Google, Rackspace, IBM, VMware etc. Cloud computing system provides the service to the user and is characterized by high scalability, portability, elasticity and reliability. The resources of the cloud computing system are transparent to the application and the user does not know the location or configuration or capacity details of the resources. The users can access data and applications from anywhere through internet which means great portability. A major challenge in cloud computing is scheduling that is to allocate tasks to available resources on the basis of task qualities, metrics and requirements without affecting the services provided by the cloud. Scheduling in cloud computing system decides how to allocate the resources such as CPU, memory, secondary storage space, I/O, network bandwidth etc. between users and tasks. A good scheduler adapts its scheduling strategy according to the changing environment over time, the nature of tasks and relative metrics of the tasks involved in batch of tasks submitted for processing. Scheduling refers to the set of policies to control the order of work to be performed by a computing system. There are various types of scheduling algorithms existing in distributed computing system, and job scheduling is one of them. The main advantage of job scheduling algorithm is to achieve a high performance computing and the best system throughput. Scheduling manages availability of resources like CPU, memory and good scheduling policy gives maximum utilization of resources. Virtual Machine (VM) is a process of mapping virtual machines to Physical Machines. As Virtualization is a core technology of cloud computing, allocation of Virtual Machines has become important challenge in cloud computing. Several research works addressed the importance of placing VMs appropriately. Recently in works [2] and [3] two stage scheduling model is designed and developed for allocation of resources in cloud to the incoming jobs in the form of Virtual machines. Load balancing affects cloud computing and improves the performance by re-distributing the load among the computing resources. Jobs are transferred from one node to another through the network. Little work is reported till date regarding cloud scheduling with load balancing strategy. Hence in this paper we designed and developed a novel efficient cloud scheduling algorithm based on load balancing analytics for allocation of physical resources in the form of virtual machine to incoming job requests.