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的更多相关文章

  1. Java® Language Specification

    Java™ Platform, Standard Edition 8 API Specification http://docs.oracle.com/javase/8/docs/api/ The J ...

  2. study java language

    2016.11.30 1).About the Java Technology 2).The Java Language Environment: Contents

  3. Java Language and Virtual Machine Specifications

    The Java Language Specification, Java SE 8 Edition HTML | PDF The Java Virtual Machine Specification ...

  4. vscode + gradle 创建 java 项目 - java language server无法启动

    1.在系统上安装一个版本的gradle,用`gradle init --type java-application`创建一个默认的java项目,假设项目目录是hellojava 2.vscode写ja ...

  5. Java Language Keywords

    Java Language Keywords 典型题目 true.false.null.sizeof.goto.synchronized 哪些是Java关键字?(goto.synchronized) ...

  6. 笔记:Java Language Specification - 章节17- 线程和锁

    回答一个问题:多线程场景下,有时一个线程对shared variable的修改可能对另一个线程不可见.那么,何时一个线程对内存的修改才会对另一个线程可见呢? 基本的原则: 如果 读线程 和 写线程 不 ...

  7. 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, ...

  8. Learning Java characteristics (Java in a Nutshell 6th)

    Java characteristics: Java .class files are machine-independent, including the endianness. Java .cla ...

  9. java 语言规范 java language specifications

    在线地址: https://docs.oracle.com/javase/specs/ java语言规范下载: 链接:http://pan.baidu.com/s/1miEpJwk 密码:f89v j ...

随机推荐

  1. 如何:通过对字符串应用 HTML 编码在 Web 应用程序中防止脚本侵入

    大多数脚本利用发生在用户可以将可执行代码(或脚本)插入您的应用程序时. 默认情况下,ASP.NET 提供请求验证.只要窗体发送包含任何 HTML,该验证都会引发错误. 您可以使用下列方法防止脚本利用: ...

  2. 已经导入了具有相同的简单名称“Interop.DSOFramer, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null”的程序集。

    错误  : 已经导入了具有相同的简单名称“Interop.DSOFramer, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null”的程序集. ...

  3. [leetcode]_Best Time to Buy and Sell Stock I && II

    一个系列三道题,我都不会做,google之答案.过了两道,第三道看不懂,放置,稍后继续. 一.Best Time to Buy and Sell Stock I 题目:一个数组表示一支股票的价格变换. ...

  4. mr的logs的查看

    在map或者reduce函数中使用System.out.println打印的信息沾满查看呢? 步骤1:启动history server /usr/local/hadoop-2.6.0/sbin/mr- ...

  5. C# winform combobox控件中子项加删除按钮(原创)

    效果如下图,本人网上搜索资料加上自己的研究终于实现了在combobox子项中加上删除按钮. 一.窗体中的代码: using System; using System.Collections.Gener ...

  6. PHP导出excel文件

    现在教教你如何导入excel文件: 在我的文件储存里面有一个com文件夹的,将其解压放在ThinkPHP/Library/文件夹里面,然后就是写控制器啦!去调用这个插件: <?php names ...

  7. spark概论

    一.概述 1.轻:(1)采用语言简洁的scala编写:(2)利用了hadoop和mesos的基础设施   2.快:spark的内存计算.数据本地性和传输优化.调度优化,使其在迭代机器学习,ad-hoc ...

  8. OC学习-1

    编译和编写代码. 1. 创建代码文件夹 mkdir lession2 2. 新建类文件 touch lession2.m 3. 打开编写代码,(会用xcode打开) open lession2.m 4 ...

  9. C#调用sap接口及返回数据到sap

    public class SapClass { /// <summary> /// /// </summary> /// <param name="fphm&q ...

  10. NOJ1103-全排列

    全排列 时间限制(普通/Java) : 1000 MS/ 3000 MS          运行内存限制 : 65536 KByte总提交 : 1148            测试通过 : 302  ...