Join
Blogs
Questions
Videos
Tags
Members
Search
 
 
Create your own blog, earn points and get popular!

Class

Deepali's picture

Java class assignment 2

Write a program which creates a class called circle. This class should have member variable called redius. Class should also have member method called calculateArea() which should calculate and display circle's area.

Create an object of this class and display it's area using calculateArea method.
0
Your rating: None
Deepali's picture

Java class assignment

Write a java program which creates a class called Person. The class should have three instance variables namely name, age and salary. These variable should of type String, int and float. Create new object of the class, set member variables and display them.
0
Your rating: None
Bharat's picture

How to call a constructor from another constructor within the class?

0
Your rating: None
Different constructor of the same class can be called using “this”. e.g.
  1. public class Q1 {
  2.  Q1(){
  3.   System.out.println("Default Constructor");
  4.  }
  5.  
  6.  Q1(String msg){
  7.   this(); //calls default constructor
  8.   System.out.println("One Argument Constructor");
  9.  }
  10. }
Rahimv's picture

Create a program to calculate factorial of a given number using recursion

0
Your rating: None
  1. import java.io.*;
  2.  
  3. class factorial
  4. {
  5.  long Factorial(int a)
  6.  {
  7.   if(a == 1)
  8.    return 1;
  9.   else
  10.    return(a*Factorial(a-1));
  11.  }
  12. }
  13.  
  14. class CalculateFactorial
  15. {
  16.  public static void main(String args[])
  17.  {
  18.   DataInputStream in = new DataInputStream(System.in);
  19.   int number;
  20.   long answer;
  21.  
  22.   try
  23.   {
  24.    factorial f1 = new factorial();
Rahimv's picture

Create a class which generates student merit list according to the percentage and total marks of three subjects

5
Your rating: None Average: 5 (1 vote)
  1. /*
  2.  * Create a class which generates student merit list. Get number of students to enter followed by
  3.  * details of each student and then display the student merit list according to the percentage and
  4.  * total marks.
  5.  */
  6.  
  7. import java.io.DataInputStream;
  8.  
  9. class Student
  10. {
  11.  int sno;
  12.  String sname;
  13.  int m[] = new int[3];
  14.  int total;
  15.  float percentage;
  16.  
  17.  void getdata()
  18.  {
Rahimv's picture

Create a class called Student with number, name and marks of 3 subjects

3
Your rating: None Average: 3 (2 votes)
  1. /*
  2.  * Create a class called Student with number, name and marks of 3 subjects. Get number of students
  3.  * to enter followed by details of each student and then display the student with highest percentage.
  4.  */
  5.  
  6. import java.io.*;
  7. class Student
  8. {
  9.  int sno;
  10.  String sname;
  11.  int m[] = new int[3];
  12.  int total;
  13.  float percentage;
  14.  
  15.  void getdata()
  16.  {
Andr's picture

Java Programming Tutorial - Class to Hold Objects

Video Tutorial: 
See video
Andr's picture

Java Programming Tutorial - 14 - Using Multiple Classes

Video Tutorial: 
See video
Syndicate content