zoukankan      html  css  js  c++  java
  • 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 jumpsover 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.

     1 import java.util.*;
     2 import java.lang.*;
     3 import java.io.*;
     4 
     5 /* Name of the class has to be "Main" only if the class is public. */
     6 class Triangle
     7 {
     8     public static void main (String[] args) throws java.lang.Exception
     9     {
    10         // your code goes here
    11         for (int row = 1; row < 20; row +=2)
    12         {
    13             for (int col = 0; col < 19 - row/2; col++)
    14                 System.out.print(" ");
    15             for (int col = 0; col < row; col++)
    16                 System.out.print("*");
    17             System.out.print("
    ");
    18         }
    19     }
    20 }

    output:

                       *
                      ***
                     *****
                    *******
                   *********
                  ***********
                 *************
                ***************
               *****************
              *******************
    
    • Summary:(省略)
  • 相关阅读:
    串口调适
    取出不重复的6个数
    个人Windows 10必备软件以及浏览器必装插件等
    合肥工业大学宣城校区2018年-2019年第一学期(大三上学期)物联网工程专业资料汇总(含课件、个人实验报告、实验代码、课设报告等)
    合肥工业大学宣城校区2019年-2020年第二(大三下)学期物联网工程专业资料汇总(含课件、个人实验报告、实验代码、课设报告等)
    合肥工业大学宣城校区2020年-2021年第一(大四上)学期物联网工程专业资料汇总(含课件、个人实验报告、实验代码、课设报告等)
    软件工程-单元测试-计算机测试-复习札记
    8086汇编计算分段函数值
    C语言是开源的吗?C++是开源的吗?C语言、C++是两个开源的标准,而不是开源软件或其它
    合肥工业大学编译原理实验LR(1)文法分析完整Scala实现代码(Java封装GUI)与测试数据
  • 原文地址:https://www.cnblogs.com/allenpengyu/p/3578729.html
Copyright © 2011-2022 走看看