Archive for category Object Core

A simple Lucky draw Program

Here I’m going to show a simple program which picks random 6 character and assigns the point for that code no.

If it consists vowel letter then

a =1, e=2, i=3, o=4,e=5

and if no any vowel letter then it is awarded by 100 pts.

If you to download code then (CLICK HERE)

The program is given below:
//import directives for Input of Keyboard
import java.util.Scanner;

public class LuckyDraw
static String name;
static int point = 0;
char[] code;
String setOfAlphabet;

public LuckyDraw(){
code = new char[6];
setOfAlphabet = “abcdefghijklmnopqrstuvwxyz”;

//looping the random character
public void loop(){

//handling two side :
//one at loop
//other at assgning the char in char array;
int i=0;

//flag of the while loop
boolean flag = true;


int b = (int)(Math.random()* setOfAlphabet.length());
code[i] = setOfAlphabet.charAt(b);

//condition for stopping loop
if(i == 6) flag = false;


//assigns the points
public void points(){

System.out.print(“Your code No\t\t\t:”);

for(char a : code){
//assing the score
if(a == ‘a’)point += 1;
if(a == ‘e’)point += 2;
if(a == ‘i’)point += 3;
if(a == ‘o’)point += 4;
if(a == ‘u’)point += 5;
//exception if there are no any vowel letter
// then give 100 point
if(point == 0) point = 100;


System.out.printf(“Your have scored\t\t:%s pts\n”,point);


//main method
public static void main (String[] args)
//giving input of name
Scanner scan = new Scanner(;
System.out.print(“Please enter your name\t:”);
name =;

//invoking the methods to display
LuckyDraw lucky = new LuckyDraw();



Tags: , , , , , , ,

A Public Vs. Nonpublic Classes

Probably we used to declare the method and class as a public .
But the there is also the classes where there is no any public
or any private .
We can make two or many classes in a single class file.
* But when declaring numerous class the class file must contain
at least one public class whose class must match to class file
Read the rest of this entry »

Tags: , , , ,

Exception Handler

Here we are going to start a exception handler of handling the occurance of error.

To start the exception we must know a few info about the try{} catch() and finally{}.

This try helps is to try any operation and if there appears any error then it directly goes to the catch() method to check either the error matches with the exception defined at catch(). If no any catch is found then it directly goes to finally{} method for end of try{} method.

Read the rest of this entry »

Tags: , , , , ,

Enum (eration) in Java

Here you can see the structure of Enum class in java. This class have their own rules and regulation.In this class there is no use of public except in the method value and class access because it doesn’t give any access to client. Some changable user-defined are written in italics.

For enum define , Just use below syntax

Read the rest of this entry »

Tags: , , , , ,

Frame Height in Applet

Actually the the height we defined for JFrame may differ as what we assume . In windows JFrame uses its height including it’s title bar and the bottom border of window frame.It can be illustrated below :
Let’s we code the JFrame size.

In syntax: JFrame_var_name.setSize(Width_px, Height_px);
foreg.  xxx.setSize(100, 100);

In this code we can see that we defined a JFrame size to 100px width and 100px height. But actually some programmer feels problem on the height of the windows size , even we had declare the size of the JFrame to 100. The JFrame height includes the title bar and it’s bottom liner height.

Read the rest of this entry »

Tags: , , , , ,