Best Java Training in Nagpur

Java program to generate random numbers

Objectives:

  • Write a Java program to to generate random numbers and print the same
  • Write a program to generate random numbers
  • Write a program to generate random numbers in Java

Java Program:

[sourcecode lang="java"]

import java.util.Scanner;
import java.util.Random;

class GenerateRandomNumber
{
public static void main(String[] args)
{
int maxRange;

//create objects
Scanner SC = new Scanner(System.in);
Random rand = new Random();

System.out.print("Please enter maximum range: ");
maxRange=SC.nextInt();

for(int i=1; i<=10; i++)
{
System.out.println(rand.nextInt(maxRange));
}
}
}

[/sourcecode]

Output:

Please enter maximum range: 500
467
61
100
449
68
316
445
224
54
498

Find duplicate characters in string

Objectives:

  • Write a Java program to find duplicate characters in the string and print the duplicate characters
  • Write a program to find duplicate characters in String

Java Program:

[sourcecode lang="java"]
public class DuplicateCharacters {
    public static void main(String args[]) {

        String str = "NITIN";
        int count = 0;

        char input[] = str.toCharArray();
        System.out.println("Duplicate Characters are:");

        for (int i = 0; i &amp;lt; str.length(); i++) {
            for (int j = i + 1; j &amp;lt; str.length(); j++) {
                if (input[i] == input [j]) {
                    System.out.println(input[j]);
                    count++;
                    break;
                }
           }
        }
    }
}
[/sourcecode]

Output:

Duplicate Characters are: N I

Passing String in Switch Case in Java

Objectives:

  • How to use switch case in Java?
  • How to use switch case with string in Java?
  • How to pass string literals in switch case in Java?

 

Source Code:

[sourcecode lang=”java”]

public class SwitchWithStringExample

{
public static void main(String[] args)
{
String str = "two";
switch(str)
{
case "one":
System.out.println("one");
break;
case "two":
System.out.println("two");
break;
case "three":
System.out.println("three");
break;
default:
System.out.println("no match");
} // switch close
} // main close
} // class close

[/sourcecode]

 

Steps to run above Java code:

Consider that we have saved code at C drive (c:\>) and the file is saved as SwitchWithStringExample.java

  1. Compilation : c:\> javac SwitchWithStringExample.java
  2. Interpretation : c:\> java SwitchWithStringExample

 

Output:

two

 

We conduct Java Training and Workshop for Corporates and College Students, if interested, please write to us on kloudsancyber@gmail.com

 

Aatul Palandurkar
International Trainer, and Author, NetBeans Dream Team Member

https://www.facebook.com/aatulpalandurkar
https://www.instagram.com/aatulpalandurkar/

Oracle Java Certifications For You

Oracle Java Certifications For You

The Java programming language is among the most widely used software development platforms in the IT industry nowadays. It is extensively being used and appreciated by individuals as well as organizations to transform their innovative ideas into working software solutions.

 

The Java programming language is among the most widely used software development platforms in the IT industry nowadays. It is extensively being used and appreciated by individuals as well as organizations to transform their innovative ideas into working software solutions.

 

Oracle Corporation is constantly working in the area of Java platform development. They provide Java certifications as well. Each of these java certifications verifies a certain level of expertise and knowledge of the Java platform belonging to specific domains.

 

Adding the best Java certification to your resume will help you grab the attention of the employer. A Java certification can validate your knowledge and expertise in working with Java. Preparing for a Java Certification can help you enhance your Java programming skills.

 

Oracle Java Certifications

 

Before diving in detail into the various Java certification courses offered by the Oracle Corporation, let’s first skim through a summarized introduction. Oracle Java certifications are categorized as follows:

 

Entry Level

  • Oracle Certified Associate Java Programmer (OCAJP)

 

Professional Level

  • Oracle Certified Professional Java Programmer (OCPJP)
  • Oracle Certified Professional Java Application Developer (OCPJAD)

 

Master/Architect Level

  • Oracle Certified Master Java Enterprise Architect (OCMJEA)

 

 

The Oracle OCP Java SE 8 Programmer I certification will validate your strong Java programming skills. To earn this certification you will have to pass the 1Z0-808 exam. The 1Z0-808 exam objectives include topics such as Java basics, Java data types, array, loop contracts, methods and encapsulation and so on.

 

 

 

The Oracle OCP Java SE 8 Programmer II certification is a professional-level certification designed to validate the foundation skills of database administration. The OCP 1Z0-809 exam objectives include exceptions and assertions; generics and collections; Java Class Design, Java File I/O (NIO.2), Java I/O Fundamentals, Java Stream API, and localization.

 

 

 

Oracle OCP Java SE 11 Developer certification covers a wide range of available Java 11 programming concepts. To earn this certification you will have to clear the 1Z0-815 exam. The Oracle 1Z0-815 exam covers topics such as Encapsulation, creating and using methods; creating simple Java programs, describing and using objects and classes; handling exceptions, Java technology, reusing implementations through Inheritance, 

understanding modules, and more.

As we all know that Java is employed for developing a wide array of applications. This programming language is used in creating server-side applications to mobile applications. So, if you are thinking about starting your career in this field, then you must consider these certifications. We offer courses that will help you prepare for the certification exams.

 

Pattern Programs in Java – Pattern 3

Pattern 3 :

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1

 

Java Code for above pattern :

[sourcecode lang=”java”]

import java.util.Scanner;

&nbsp;

public class Pattern3

{

public static void main(String[] args)

{

Scanner sc = new Scanner(System.in);

//Taking rows value from the user

System.out.println("How many rows you want in this pattern?");

int rows = sc.nextInt();

System.out.println("Here is your pattern….!!!");

//Printing upper half of the pattern

for (int i = 1; i <= rows; i++)

{

for (int j = 1; j <= i; j++)

{

System.out.print(j+" ");

}

System.out.println();

}

//Printing lower half of the pattern

for (int i = rows-1; i >= 1; i–)

{

for (int j = 1; j <= i; j++)

{

System.out.print(j+" ");

}

System.out.println();

}

//Closing the resources

sc.close();

}

}

[/sourcecode]

Output :

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1

 

Pattern Programs in Java – Pattern 2

Pattern 2 :

1
2 2
3 3 3
4 4 4 4
5 5 5 5 5

Java Program for the above pattern:

[sourcecode language=”java”]

import java.util.Scanner;

public class MainClass

{

public static void main(String[] args)

{

Scanner sc = new Scanner(System.in);

//Taking rows value from the user
System.out.println("How many rows you want in this pattern?");

int rows = sc.nextInt();

System.out.println("Here is your pattern….!!!");

for (int i = 1; i <= rows; i++)

{

for (int j = 1; j <= i; j++)

{

System.out.print(i+" ");

}

System.out.println();

}

//Close the resources
sc.close();

}

}

[/sourcecode]

Pattern Programs In Java – Pattern 1

Q. Write a Java program to print given pattern.

Pattern 1 :

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6 7

 

Java Program:

[sourcecode language=”java”]

import java.util.Scanner;

public class MainClass

{

public static void main(String[] args)

{

Scanner sc = new Scanner(System.in);

//Taking rows value from the user

System.out.println("How many rows you want in this pattern?");

int rows = sc.nextInt();

System.out.println("Here is your pattern….!!!");

for (int i = 1; i <= rows; i++)

{

for (int j = 1; j <= i; j++)

{

System.out.print(j+" ");

}

System.out.println();

}

//Close the resources

sc.close();

}

}

[/sourcecode]