Documentation

The Java™ Tutorials
Hide TOC
Questions and Exercises问题和练习
Trail: Learning the Java Language
Lesson: Language Basics

Questions and Exercises: Variables问题和练习:变量

Questions问题

  1. The term "instance variable" is another name for ___.术语“实例变量”是非静态字段的另一个名称。
  2. The term "class variable" is another name for ___.术语“类变量”是静态字段的另一个名称。
  3. A local variable stores temporary state; it is declared inside a ___.局部变量存储临时状态;它是在一个方法中声明。
  4. A variable declared within the opening and closing parenthesis of a method signature is called a ____.在方法签名的左括号和右括号内声明的变量称为形参
  5. What are the eight primitive data types supported by the Java programming language?Java编程语言支持的八种基本数据类型是什么?byteshortintlongfloatdoublebooleanchar
  6. Character strings are represented by the class ___.字符串由类java.lang.String表示。
  7. An ___ is a container object that holds a fixed number of values of a single type.数组是一个容器对象,它包含固定数量的单一类型的值。

Exercises练习

  1. Create a small program that defines some fields.创建一个定义一些字段的小程序。Try creating some illegal field names and see what kind of error the compiler produces.尝试创建一些非法的字段名,看看编译器会产生什么样的错误。Use the naming rules and conventions as a guide.使用命名规则和约定作为指南。
  2. In the program you created in Exercise 1, try leaving the fields uninitialized and print out their values.在练习1中创建的程序中,尝试保持字段未初始化并打印其值。Try the same with a local variable and see what kind of compiler errors you can produce.对局部变量进行同样的尝试,看看会产生什么类型的编译器错误。Becoming familiar with common compiler errors will make it easier to recognize bugs in your code.熟悉常见的编译器错误将更容易识别代码中的错误。

Check your answers检查你的答案


Previous page: Summary of Variables
Next page: Operators