文档介绍:java基础题(java基础题)
1. Write statements, statements, or annotations plete the following tasks:
A) that a program pute the product of 3 integers.
B) create a Scanner object input. that reads data from a standard input device
C) declare int type variables X, y, Z, and result.
D) prompts the user to enter the first integer.
E) reads the first integer from the user input and stores it in the variable x.
F) prompts the user to enter second integers.
G) reads second integers from the user input and stores them in the variable y.
H) prompts the user to enter third integers.
I) reads third integers from the user input and stores them in the variant Z.
K) displays the value of the message "Product is" and the variable result.
Import ;
/ * *
* class name:
* Description: calculates the product of 3 integers
* /
Public class Product {
Public static void main (String[] args) {
Scanner input = new Scanner ();
Int x, y, Z, result;
("please input first integer to x:");
X = ();
("please input second integer to y:");
Y = ();
("please input third integer to z:");
Z = ();
Result = x*y*z;
("Product is" +result);
}
}
2, to achieve file replication function:
Requirements: write a Java program to copy C:\demo\ files to D:\dest\ and E:\dest\. .
Import ;
Import ;
Import ;
Import ;
Import ;
Import ;
Import ;
Import ;
/ * *
* class name:
Description: write a Java program to copy C:\demo\ files to D:\dest\ and E:\dest\. .
* /
Public class CopyZipFile {
Public static void CopyFile (InputStream inputStream, String destpath) {
File targetFile = new File (destpath