Learn Programming in Java

Learn Hands-On Programming in Java

Welcome to the ekgurukul.com website! This Programming in Java Tutorial helps you learn the concept of language quickly and effectively. If you are not sure where to start learning Programming in Java language.

Website ekgurukul.com is a good place to start your Learning.

Java is a powerful general-purpose programming language. It is used to develop desktop and mobile applications, big data processing, embedded systems, and so on. According to Oracle, the company that owns JavaJava runs on 3 billion devices worldwide, which makes Java one of the most popular programming languages.

Java is an object-oriented, class-based, concurrent, secured and general-purpose computer-programming language. It is a widely used robust technology.

Java was developed by Sun Microsystems (which is now the subsidiary of Oracle) in the year 1995. James Gosling is known as the father of Java. Before Java, its name was Oak. Since Oak was already a registered company, so James Gosling and his team changed the Oak name to Java.

Platform: Any hardware or software environment in which a program runs, is known as a platform. Since Java has a runtime environment (JRE) and API, it is called a platform.

The basic steps to create the Hello World program are: write the program in Java, compile the source code, and run the program.

  1. Write the Java Source Code. ...
  2. Save the File. ...
  3. Open a Terminal Window. ...
  4. The Java Compiler. ...
  5. Change the Directory. ...
  6. Compile Your Program. ...
  7. Run the Program.

Different Types of Java Applications

There are mainly 4 types of applications that can be created using Java programming:

  1. Standalone Application: These are traditional software that we need to install on every machine. They are also known as desktop applications or window-based applications
  2. Web Application: An application that runs on the server-side and creates a dynamic page is called a web application. Some technologies like Servlet, JSP, Struts, Spring, etc are used for creating web applications in Java.
  3. Enterprise Application: An application that is distributed in nature, such as banking applications, etc. is called an enterprise application. It has advantages of high-level security, load balancing, and clustering. EJB is used for creating enterprise applications.
  4. Mobile Application: An application that is created for mobile devices is called a mobile application. Currently, Android and Java ME are used for creating mobile applications.

Here are some of the benefits of taking a programming in Java course:

  • Learn the fundamentals of the Java programming language
  • Gain experience with object-oriented programming concepts
  • Develop your problem-solving skills
  • Learn how to write efficient and reusable code
  • Prepare for a career in software development

If you are interested in learning Java, I recommend taking a programming in Java course. There are many online and in-person courses available, so you can find one that fits your needs and schedule.

Here are some of the most popular programming in Java courses:

  • Introduction to Java Programming by Duke University on Coursera
  • Object-Oriented Programming in Java by University of California San Diego on Coursera
  • Core Java by LearnQuest
  • Introduction to Java by LearnQuest
  • Introduction to Java and Object-Oriented Programming by University of Pennsylvania on Coursera

First of all, I must say you cannot learn something like java or any programming language in one day. If you have any prior knowledge of any programming language you should already know that. But if you want to learn it really fast what you can do is start watching a series of online tutorials.

Complete Programming in Java Tutorials

Let’s see what’s so special in Programming in Java, what we can achieve with it, let's start Learning ...

Publish Your Article / Write for Us

We covered different topics like Digital Marketing Techniques, Technology-based Education, Sports activities and travel information sharing, Culture, and Society Improvement and related content areas but we’re open to other designs, concepts and ideas as well. All articles having unique content at least 600-700 words. Article will be published max for one year. The article having proper headings, subheadings, and paragraphs, images must be well-formatted.

Article Writing Guide/Help

Subject : Programming in Java /Programming / Lab / Manual

Student can access the solutions for preparation competitive exams

import java.util.*;

class Average{

public static void main(String args[ ]) {    

Scanner sc= new Scanner(System.in);

int a=0,min=0,max=0,x;

int n =args.length;
System.out.println("1-sum");

System.out.println("2-Average");

System.out.println("3-Minimum");

System.out.println("4-Maximum");

System.out.println("Enter Ur Choice : ");

choice=sc.nextInt();

for(int i=0;i<n;i++){

a+=Integer.parseInt(args[i]);//to convert string into Integer 

}

switch(choice){

case 1 :System.out.println("The sum is : "+a);

break;

case 2 :System.out.println("The Average is : "+a/n);

break;

case 3 : for(int i=0;i<n-1;i++){    

x=Integer.parseInt(args[i]); if(x<Integer.parseInt(args[i+1]))

min=x;

else

min=Integer.parseInt(args[i+1]);

}

System.out.println("The minimum is : "+min); break;

case 4 :

for(int i=0;i<n-1;i++) {    

x=Integer.parseInt(args[i]);

if(x>Integer.parseInt(args[i+1]))

max=x;

else

max=Integer.parseInt(args[i+1]);

}

System.out.println("The maximum is : "+max);

break;
}
}
}

class typecast {

public static void main(String args[]) {

byte h=127;

int a=300;

float a1=12.222f;

float g;

short b=200;

long c=999999;

float e=345.89F;

double f=45645.78222222222222;

g= (float)f;

System.out.println("short b ="+g);

System.out.println("short b ="+b);

System.out.println("long c ="+c);

System.out.println("float e="+e);

System.out.println("double f="+f);

System.out.println("short b="+b);

System.out.println("short to byte "+(byte)b);

System.out.println("int to byte "+(byte)a);

System.out.println("int to float"+(float)a);

System.out.println("long to byte "+(byte)c);

System.out.println("double to long "+(long)f);

System.out.println("double to int "+(int)f);

System.out.println("double to byte "+(byte)f);

System.out.println("double to short "+(short)f);

System.out.println("double to float "+(float)f);

System.out.println("float to int "+(int)e);

System.out.println("float to byte "+(byte)e);

System.out.println("float to short "+(short)e);

System.out.println("float to long "+(long)e);

System.out.println("float to double ="+(double)e);

System.out.println("long to int"+(int)c);

System.out.println("byte to int ="+(int)h);

}

}

import java.util.*;

class prime {

public static void main(String args[]) {

int flag,x,i;

flag=0;

int a[]=new int[7];

for(x=0;x<args.length; x++)

{

a[x]=Integer.parseInt(args[x]);

for(i=2;i<(a[x]/2);i++) {

if((a[x]%i)==0)

{

break;

}

else flag=1;

}

if(flag==1)

System.out.println(a[x]+" is a prime no ");

else

System.out.println(a[x]+" is not a prime no ");

flag=0;

}

}

}

import java.util.*;

class hcf {

public static void main(String args[]) {

int a,b;

Scanner sc= new Scanner(System.in);

System.out.println("Enter two nos :");

a=sc.nextInt();

b=sc.nextInt();

int big; int small;

if(a>b) {

big=a; small=b;

} else {

big=b; small=a;

}

for(int i=1;i<=big;i++) {

if(((big*i)%small)==0)

{

int lcm=big*i;

System.out.println("The least common multiple is "+(lcm));

break;

}

}

int temp=1;

while(temp!=0)

{

temp=big%small;

if(temp==0) {

System.out.println("GCD is "+small);

}

else {

big=small;

small=temp;

}

}

}

}

import java.util.*;

class si {

int p,t; float si,r;

public si() {

r=0; p=0;

}

public void getdata() {

Scanner sc =new Scanner(System.in);

System.out.println("Enter principle : ");

p=sc.

nextInt();

System.out.println("Enter rate : ");

r=sc.

nextFloat();

System.out.println("Enter time period : ");

t=sc.

nextInt();

}

public void cal() {

si=(p*r*t)/100;

}

public void display() {

System.out.println("Principle : Rs"+p);

System.out.println("Rate : "+r);

System.out.println("Time period : "+t);

System.out.println("Simple Interest : Rs"+si);

}

public static void main(String args[]) {

si s = new si();

s.getdata();

s.cal();

s.display();

}

}

class rect {

int l,b;

public rect(int l,int b) {

this.l=l;

this.b=b;

}

public int area() {

return l*b;

}

}

class box extends rect {

int d;

public box(int l,int b,int d) {

super(l,b);

this.d=d;

}

public int volume() {

int vol = area()*d;

return vol;

}

public static void main(String args[]) {

int vol ,area;

System.out.println("derived object in derived reference");

rect r = new rect(10,20);

area=r.area();

System.out.println("area is "+area+"\n");

System.out.println("base object in base reference");

box b = new box(10,20,30);

vol=b.volume();

area=b.area();

System.out.println("area is "+area);

System.out.println("volume is "+vol+"\n");

System.out.println("derived object in base reference");

rect b1= new box(10,90,70);

area = b1.area();

//vol=b1.volume(); as with refernce of base class we can't call derived's method 

System.out.println("area is "+area);

//as super class doesn't knw abt the base class but reference can be assigned 

 /*System.out.println("base object in derived reference");

box b2=(new rect (10,20));

vol = b2.area();

System.out.println("area is "+area);*/

r=b; S

ystem.out.println(r.area());

System.out.println(r.volume());

}

}

class NestedTry {

public static void main(String args[]) {

int a=args.length;

try{

int d=42/a;

try {

if(a==1){

int c= a/(a-a);

}

if(a==2) {

int c[]={2,3,4};

c[5]=90;

}

}

catch(ArrayIndexOutOfBoundsException e)

{

e.printStackTrace();

}

}

catch(ArithmeticException e)

{

e.printStackTrace();

}

}

}

class ThrowDemo {

ThrowDemo() {

try {

throw new NullPointerException();

}

catch(NullPointerException e) {

System.out.println("Caught in constructor");

throw e;

}

}

public static void main(String args[]) {

try{

ThrowDemo td=new ThrowDemo();

}

catch(NullPointerException e) {

System.out.println("Caught in Main");

}

}

}

class ThrowsDemo {

ThrowsDemo() throws NullPointerException {

System.out.print("in constructor");

throw new NullPointerException();

}

public static void main(String args[]) {

try{

ThrowsDemo td=new ThrowsDemo();

}

catch(NullPointerException e) {

System.out.println("Caught in Main");

}

}

}

import java.util.*;

class MyException extends Exception {

private int e;

MyException (int a ) {

e=a;

}

public String toString()

{

return ("Error in entry"+e);

}

}

public class mine {

public void compute(int a) throws MyException {

int age=a;

if(age>150) throw new MyException (age);

System.out.println("Correct age");

}

public static void main(String args[]) {

mine m=new mine();

try{ m.compute(1);

m.compute(789);

}

catch(MyException e) {

System.out.println(e);

}

}

}

package pack;

class base {

public static void main(String arg[]) {

System.out.println("Base class(p1)");

p1 w=new p1();

System.out.println("Derived class(p2)");

p2 x=new p2();

System.out.println("Simple class(p3)");

p3 y=new p3();

}

}

public class p1 {

int a=1;

public int b=2;

private int c=3;

protected int d=4;

public p1() {

System.out.println("Value of a="+a);

System.out.println("Value of b="+b);

System.out.println("Value of c="+c);

System.out.println("Value of d="+d);

}

}

package pack;

class p2 extends p1 {

p2() {

System.out.println("Value of a="+a);

System.out.println("Value of b="+b);

System.out.println("Value of c="+c);

System.out.println("Value of d="+d);

}

}

package pack; class p3 {

p1 p=new p1();

p3() {

System.out.println("Value of a="+(p.a));

System.out.println("Value of b="+(p.b));

System.out.println("Value of c="+(p.c));

System.out.println("Value of d="+(p.d));

}

}

package pack1;

class simple extends pack.p1 {

public simple() {

System.out.println("Value of a="+a);

System.out.println("Value of b="+b);

System.out.println("Value of c="+c);

System.out.println("Value of d="+d);

}

}

package pack1;

class s2 {

public static void main(String arg[]) {

simple s=new simple();

s1 p=new s1();

}

}

package pack1;

class s1 {

s1() {

pack.p1 z=new pack.p1();

System.out.println("Value of a="+(z.a));

System.out.println("Value of b="+(z.b));

System.out.println("Value of c="+(z.c));

System.out.println("Value of d="+(z.d));

}

}