Learning Java language Fundamentals
Chapter 2 Learning Java language fundamentals
- exercises:
1.What is Unicode?
Unicode is a computing industry standard for consistently encoding,representing,and handling text that's expressed in most of world's writing system
2.What is a comment?
A comment is language feature for embedding documentation in source code
3.Identify the three kinds of comments that Java supports.
single-line,multiline,javadoc
4.What is an identifier?
An identifier is a language feature that consist of letter (A-Z,a-z,or equivalent uppercase/lowercase letters in other human alphabets),digits (0-9 or equivalent digits in other human alphabets),connecting punctuation characters,and currency symbols.This name must begin with a letter,a currency symbol,or a connecting punctuation character;and its length cannot exceed the line in which it appears.
5.True or false: Java is a case-insensitive language.
False.Java is a case-sensitive language.
6.What is type?
A type is a language feature that identifies a set of values (and their representation in memory) and a set of operations that transform these values into other values of that set.
7.define primitive type?
A primitive type is a type that's defined by the language and whose values are not objects.
8.Identify all of Java's primitive types.
Boolean,character,byte integer,short integer,integer,long integer,floating-piont,double precision floating-point
9.Define user-define type.
A user-defined type is a type that's defined by the developer using a class, an inteface,an enum,or an annotation type and whose values are objects.
10.Define array type.
A array type is a special reference type that signifies an array,a region of memory that stores values in equal-size and contiguous slots,which are commonly referred to as elements.
11.What is variable?
A variable is a named memory location that stores some type of value.
12.what is an expression?
An eexpression is a combination of literals,variable names,methods calls,and operators.At runtime,it evaluates to a value whose type is referred to as the expression's type
13.Identiy the two expression categories.
simple expression and compound expression
14.What is a literal?
a value specified verbatim(字面的)
15.Is string literal"The quick brown fox \jumps\over the lazy dog."legal or illegal?Why?
It's illegal.(转义字符)should be "The quick brown fox \\jumps\\over the lazy dog."
16.What is an operator?
An operator is a sequence of instructions symbolically represented in source code.
17.Identify the difference between a prefix operator and a postfix operator.
A prefix operator precedes its operand and a postfix operator trails its operand.
18.What is the purpose of the cast operator?
To convert from one type to another type.for example:floating-piont to 32-bit integer
19.What is precedence?
an operator's level of importance(优先级)
20.True or false: Most of the Java's operator are left-to-right associative. True
21.What is statement?
A statement is a language feature that assigns a value to a variable, conrols a program's flow by making a decision and/or repeatedly executing another statement,or performs another task.
22.What is the difference between the wile and do-while statement?
The while statement evaluates its Boolean expression at the top of the loop,whereas the do-while statement evaluates its Boolean expression at the bottom of the loop.As a result, whie executes zero or more times,whereas do-while executes one or more times.
23.What is the difference between the break and continue statement?
Break transfers execution to the first statement following a switch statement or a loop,whereas continue skips the remainder of the current loop iteration,reevaluates the loop's Boolean expression,and performs another iteration (when true) or terminates the loop (when false).
24.Create a Triangle application whose Triangle class's main() method uses a pair of nested for statements along with System.out.print() to output a 10-row triangle of asterisks,where each row contains an odd number of asterisks (1,3,5,7 and so on),as shown following:
*
***
*****
............
compile and run this application.
import java.util.*;
import java.lang.*;
import java.io.*; /* Name of the class has to be "Main" only if the class is public. */
class Triangle
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
for (int row = 1; row < 20; row +=2)
{
for (int col = 0; col < 19 - row/2; col++)
System.out.print(" ");
for (int col = 0; col < row; col++)
System.out.print("*");
System.out.print("\n");
}
}
}
output:
*
***
*****
*******
*********
***********
*************
***************
*****************
*******************
- Summary:(省略)
Learning Java language Fundamentals的更多相关文章
- Java® Language Specification
Java™ Platform, Standard Edition 8 API Specification http://docs.oracle.com/javase/8/docs/api/ The J ...
- study java language
2016.11.30 1).About the Java Technology 2).The Java Language Environment: Contents
- Java Language and Virtual Machine Specifications
The Java Language Specification, Java SE 8 Edition HTML | PDF The Java Virtual Machine Specification ...
- vscode + gradle 创建 java 项目 - java language server无法启动
1.在系统上安装一个版本的gradle,用`gradle init --type java-application`创建一个默认的java项目,假设项目目录是hellojava 2.vscode写ja ...
- Java Language Keywords
Java Language Keywords 典型题目 true.false.null.sizeof.goto.synchronized 哪些是Java关键字?(goto.synchronized) ...
- 笔记:Java Language Specification - 章节17- 线程和锁
回答一个问题:多线程场景下,有时一个线程对shared variable的修改可能对另一个线程不可见.那么,何时一个线程对内存的修改才会对另一个线程可见呢? 基本的原则: 如果 读线程 和 写线程 不 ...
- Learning Java 8 Syntax (Java in a Nutshell 6th)
Java is using Unicode set Java is case sensitive Comments, C/C++ style abstract, const, final, int, ...
- Learning Java characteristics (Java in a Nutshell 6th)
Java characteristics: Java .class files are machine-independent, including the endianness. Java .cla ...
- java 语言规范 java language specifications
在线地址: https://docs.oracle.com/javase/specs/ java语言规范下载: 链接:http://pan.baidu.com/s/1miEpJwk 密码:f89v j ...
随机推荐
- VMware下安装的Mac OS X如何修改显示分辨率
VMware下安装的Mac OS X如何修改显示分辨率 我在Win7下利用VMware安装了苹果的Mac OS,安装成功启动后,发现分辨率为1920*1080,而宿机的分辨率是1366*768,我 ...
- sprintf函数减少字符串拼接错误
$return_string=""; foreach($cat_list as $value){ $return_string .= sprintf('<dd>< ...
- php判断是否为json格式的方法
php判断是否为json格式的方法. 首先要记住json_encode返回的是字符串, 而json_decode返回的是对象 判断数据不是JSON格式: 复制代码代码如下: function is_n ...
- java基础笔记
1. 成员变量会自动的进行初始化,但是局部变量不会: 2. equals传引用值,==传地址值:当一个对象是引用类型时,就必须使用equals进行比较. 3. 继承:实现代码的复用,继承关系以一种验证 ...
- does not match bootstrap parameter
问题描述: DBD::mysql object version 2.0419 does not match bootstrap parameter 2.0902 at /usr/libdata/per ...
- 数据结构学习笔记05图(最小生成树 Prim Kruskal)
最小生成树Minimum Spanning Tree 一个有 n 个结点的连通图的生成树是原图的极小连通子图,且包含原图中的所有 n 个结点,并且有保持图连通的最少的边. 树: 无回路 |V|个顶 ...
- jquery mobile最棘手的一个问题
大多数jquery mobile开发的妹子们都碰到过这个问题: 如何调用loading效果 这里给出一段代码,赶紧练手吧. //显示loading function showLoading(){ ...
- angularjs2 学习笔记(六) Form
Angular 2 Form表单 在angular2 form表单中我们需要了解表单数据绑定.数据验证.数据提交等内容,在下面的示例中并没有实际提交到后台,这部分内容在今后webapi中加以练习. 表 ...
- WdatePicker 动态变量表
4. 日期范围限制静态限制 注意:日期格式必须与 realDateFmt 和 realTimeFmt 一致 你可以给通过配置minDate(最小日期),maxDate(最大日期)为静态日期值,来限定日 ...
- Swift 类构造器的使用
Swift 中构造器需要遵循的规则还是很多的, 总结一下, 有以下规则: 调用相关 指定构造器必须调用它直接父类的指定构造器方法. 便利构造器必须调用同一个类中定义的其它初始化方法. 便利构造器在最后 ...