7th jobs ---- access, use objects

Problem 1: 5 on the basis of the job, and then creating a column type, comprising a rectangle, and the high volume of the three member variables, a constructor method to initialize member variables, and calculating the volume, for the bottom two functions method, main category input length, width, height, calculated cylinder volume, enter a new length, width, height, creating a new rectangle, the method using soled soled, the cylinder volume is calculated again.

A source code

 

 

 

 

 

 2. Run results

 

 

 

 

 

Question 2

A,: Design class called MyInteger, comprising: int type value a data field construction method, when the specified int value, object data created MyInteger field value and the access modifier isEven () and isOdd () method, if the current object is even or odd, class method returns true isPrime (MyInteger i), determines whether the specified value is a prime number, returns true MyInteger create objects in the main class, each class verification methods MyInteger

Second, the source

1.MyInteger.java

Copy the code

2.Test

Third, the result of the operation

 

Guess you like

Origin www.cnblogs.com/wjq98/p/11559823.html
7th
7th