Share on Google+Share on Google+

1 Answer(s)      7 years ago
Posted in : Java Interview Questions
View Answers

December 23, 2009 at 12:50 PM

Hi Friend,

Try the following code:

import java.util.*;
class die{

int i=1;
public int rollDie(){
int num=(int)(Math.random() * 6) + 1;

return num;

public static void main(String[] args)
die d=new die();
int num=d.rollDie();

Hope that it will be helpful for you.


Related Tutorials/Questions & Answers:
plz plz plz inform me as soon as possible
plz plz plz inform me as soon as possible  ``by using c programs how to type
plz help
plz help  what is the procedure and code to design an interactive GUI in java using swings
plz give me answer plz
plz give me answer plz  writw a programme to find rank from an array using doubledimmensionalarray
Plz Help
Plz Help  Hello Guys!! Plz. Help I need to write a program to display the astrological sign based on your birthday for example If we enter the date of birth in the following format from console--13/08/1990 it should give you
plz plz rply as soon as possible
plz plz rply as soon as possible  by using c programs * * * * * s s s s s * s s o s s s s s s s s s s s s s s s s s s s s s s s
Plz Plz reply Me - JSP-Servlet
Plz Plz reply Me  Respected Sir/madam, I am R.Ragavendran.. Actually I got your coding.. But This code is not enabling the user to click and change the image.. I request you to remember the code which you have provided for me
plz help me today plz plz - Java Interview Questions
plz help me today plz plz  2.) Suppose list is an array of six elements of type int. What is stored in list after the following java code executes? . for (i = 0; i < 5; i++) { list[i] = 2 * i + 5
plz give me answer
plz give me answer   description about string class methods   Java string methods
plz give me answer
plz give me answer   description about string class methods   Java string methods
plz give me answer
plz give me answer   description about string class methods   Java string methods
Help me quickly plz??
Help me quickly plz??  Can you help me to write code quickly this code is a java code take input as double and should use command line arguments and enhanced for statement then find the combine of the numbers plz help quickly
plz give me answer
plz give me answer  Discuss & Give brief description about string class methods   Java string methods
plz send code for this
plz send code for this  Program to calculate the sum of two big numbers (the numbers can contain more than 1000 digits). Don't use any library classes or methods (BigInteger etc
Plz send - Java Beginners
Plz send  Hi, please send whole code i understood ur sending sql query Thanks  hai dear frnd........ look how can i write... be a troublesome...then again wat r ur needs.... so plz...provide a deatiled structure
Java application PLZ ?
Java application PLZ ?  Write an application that demonstrates each of the following methods, based on the statement String dedicate = ?Dedicated to making your event a most memorable one:; indexOf(?D?) charAt(15) endsWith(one
plz help me for this question
plz help me for this question  Apply simplex procedure to solve the L.P.P. maximize z = 3x1 + 4x2 subject to 5x1 + 4x2 ? 200; 3x1 + 5x2 ? 150; 5x1 + 4x2 ? 100; 8x1 + 4x2 ?? 80, x1 ? 0, x2 ? 0
Plz answer - Java Beginners
Plz answer  Create a Java Bean Class ?? Customer according to the below given class diagram. Customer... ------------------------------------------------- plz doreply me....thankz alot  
plz tell me
plz tell me  how to get no. of times the 'button' is pressed   Here is a java swing code that counts the number of times the button clicked. import javax.swing.*; import java.awt.event.*; public class
plz solve my query?
plz solve my query?  how to remove all the options from select control in html using java script?   JavaScript remove all items <html> <script language="javascript" > function removeAllItems(selectbox
plz help me find a program
plz help me find a program  plz help..i want a source code in jsp for order processing
plz answer - Java Beginners
plz answer   Write a Binary Search program that searches an array of ordered data. Compose an ordered array of 500 integers that contains the following series of numbers and run the search on it: 1, 2, 3, 5, 8, 13, 21, 34, 55
Plz give java coding for this
Plz give java coding for this   ****** * * * *********** * * * ******   Hello Friend; below is the code : public class Pattern { public static void main(String[] args) { int
ArrayList question plz solve it
ArrayList question plz solve it  An arraylist object stores an Emp Object, where there is name,age,address of the employee is stored, And i want to access the data in the basis of age based? Provide answer to the question
java coding help plz ?
java coding help plz ?  Given two integers N and M (N â?¤ M), output all the prime numbers between N and M inclusive, one per line. N and M will be positive integers less than or equal to 1,000,000,000. The difference
Gui plz help
Gui plz help   Create a Java application that would allow a person to practice math (either addition, subtraction, multiplication or division). The questions must be randomly generated ( the values for each number should
plz help me - Java Beginners
plz help me  Deepak I can write a sessioon code plz help me admin_home.jsp page is display but data is not disply plz help me what is wrong
Plz Help Me
Plz Help Me  Write a program for traffic light tool to manage time giving between Main-Street and sub-Street. firstly, give green light for 40 seconds of the Main Street and then gives 15 second for the sub-street taking
plz help - Java Beginners
plz help  i have to programs and it takes too long to run them so i got a solution that makes programs run much faster which is threading programming.. but i dont know how to aplly that on my 2 programs: the first code
plz help me - Java Beginners
plz help me  Hi, I want to search all field from database using name, and display in text box, then data is update and delete. i want to search name using alphabets a-z, plz reply fast. plz help me this is very urgent
plz Help me - Java Beginners
plz Help me  Hi, I want learn struts,I dont have any idea about this plz help how can i make a framework.If u have any information then plz send my personal id plz tell me that whose software installed.and give me brief
plz help meto solve this question
plz help meto solve this question  for a file that exist what will be the length() method in the file class return


Advertisement null