Learning Java language Fundamentals

2023-11-09

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.

 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("\n");
18         }
19     }
20 }

output:

                   *
                  ***
                 *****
                *******
               *********
              ***********
             *************
            ***************
           *****************
          *******************

 

  • Summary:(省略)

 

转载于:https://www.cnblogs.com/allenpengyu/p/3578729.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Learning Java language Fundamentals 的相关文章

  • 如何在 Spring Data 中选择不同的结果

    我在使用简单的 Spring Data 查询或 Query 或 QueryDSL 在 Spring Data 中构建查询时遇到问题 如何选择三列 研究 国家 登录 不同的行 并且查询结果将是用户对象类型的列表 Table User Id S
  • JDK 文档是语言规范的一部分吗?

    只有一名官员Java语言规范 https docs oracle com javase specs jls se8 html index html所有 Java 实现都必须遵守它 API文档怎么样 所有Java实现都需要遵守吗这个版本 ht
  • Java:无法从同一包中的不同类访问静态变量

    这很奇怪 因为我有一个可以访问 Frame dimension getWidth 的 Character 类 及其伙伴 getHeight 但是当我想在 Map 类中使用它时 Eclipse 强调了它并且无法给我反馈 运行该程序最终会出现
  • 打印星号的 ASCII 菱形

    我的程序打印出这样的钻石 但只有当参数或菱形的每一面为4 例如如果我输入6 底部三角形的间距是错误的 我一直在试图找出答案 当参数改变时 底部的三角形不会改变 只有顶部的三角形会改变 它只适用于输入4 public static void
  • 通往楼梯顶部的可能路径

    这是一个非常经典的问题 我听说谷歌在他们的面试中使用过这个问题 问题 制定一个递归方法 打印从楼梯底部到楼梯顶部的所有可能的独特路径 有 n 个楼梯 您一次只能走 1 步或 2 步 示例输出 如果它是一个有 3 级楼梯的楼梯 1 1 1 2
  • 如何将 Mat (opencv) 转换为 INDArray (DL4J)?

    我希望任何人都可以帮助我解决这个任务 我正在处理一些图像分类并尝试将 OpenCv 3 2 0 和 DL4J 结合起来 我知道DL4J也包含Opencv 但我认为它没什么用 谁能帮我 如何转换成 INDArray 我尝试阅读一些问题here
  • 使用 JUnit 时,有没有办法验证测试方法中是否调用了 try/catch 指令的 Catch 部分?

    例如 如果我想测试以下课程 public class SomeClass public void someMethod try Some code where comething could go wrong catch Exception
  • 如何检测 Java 字符串中的 unicode 字符?

    假设我有一个包含 的字符串 我如何找到所有这些 un icode 字符 我应该测试他们的代码吗 我该怎么做呢 例如 给定字符串 A X 我想将其转换为 AYXY 我想对其他 unicode 字符做同样的事情 并且我不想将它们存储在某种翻译映
  • 使用 Guice 优化注册表

    你好 今天思考了一种优化 有一些疑问 语境 我正在使用 Guice 2 进行 Java 开发 在我的网络应用程序中 我有一个转换器注册表 可以即时转换为某种类型 转换器描述如下 public class StringToBoolean im
  • 生成的序列以 1 开头,而不是注释中设置的 1000

    我想请求一些有关 Hibernate 创建的数据库序列的帮助 我有这个注释 下面的代码 在我的实体类中 以便为合作伙伴表提供单独的序列 我希望序列以 1000 开头 因为我在部署期间使用 import sql 将测试数据插入数据库 并且我希
  • 了解joda时间PeriodFormatter

    我以为我明白了 但显然我不明白 你能帮我通过这些单元测试吗 Test public void second assertEquals 00 00 01 OurDateTimeFormatter format 1000 Test public
  • 如何在 Spring 属性中进行算术运算?

  • Java实现累加器类,提供Collector

    A Collector具有三种通用类型 public interface Collector
  • 如何在 Java 中创建接受多个值的单个注释

    我有一个名为 Retention RetentionPolicy SOURCE Target ElementType METHOD public interface JIRA The Key Bug number JIRA referenc
  • Hamcrest Matchers - 断言列表类型

    问题 我目前正在尝试使用 Hamcrest Matchers 来断言返回的列表类型是特定类型 例如 假设我的服务调用返回以下列表 List
  • 哪些属性有助于运行时 .Net 性能?

    我正在寻找可用于通过向加载器 JIT 编译器或 ngen 提供提示来确保 Net 应用程序获得最佳运行时性能的属性 例如我们有可调试属性 http msdn microsoft com en us library k2wxda47 aspx
  • OpenCSV:将嵌套 Bean 映射到 CSV 文件

    我正在尝试将 bean 映射到 CSV 文件 但问题是我的 bean 具有其他嵌套 bean 作为属性 所发生的情况是 OpenCSV 遍历属性找到一个 bean 然后进入其中并映射该 bean 内的所有数据 如果找到另一个 bean 它就
  • org.apache.commons.net.io.CopyStreamException:复制时捕获 IOException

    我正在尝试使用以下方法中的代码将在我的服务器中创建的一些文件复制到 FTP 但奇怪的是我随机地低于错误 我无法弄清楚发生了什么 Exception org apache commons net io CopyStreamException
  • 在浏览器刷新中刷新检票面板

    我正在开发一个付费角色系统 一旦用户刷新浏览器 我就需要刷新该页面中可用的统计信息 统计信息应该从数据库中获取并显示 但现在它不能正常工作 因为在页面刷新中 java代码不会被调用 而是使用以前的数据加载缓存的页面 我尝试添加以下代码来修复
  • 在java中使用多个bufferedImage

    我正在 java 小程序中制作游戏 并且正在尝试优化我的代码以减少闪烁 我已经实现了双缓冲 因此我尝试使用另一个 BufferedImage 来存储不改变的游戏背景元素的图片 这是我的代码的相关部分 public class QuizApp

随机推荐

  • DOM 的属性

    1 nodeName nodeName 属性规定节点的名称 nodeName 是只读的 元素节点的 nodeName 与标签名相同 属性节点的 nodeName 与属性名相同 文本节点的 nodeName 始终是 text 文档节点的 no
  • input的value值在页面上被改变,但是查看器代码中值不改变

    这里需要用attr 写入 而不使用val 方法 另外如果想动态改值一定不要用disabled disabled 用readonly true 代替
  • Go GPM 调度器介绍

    Go GPM 调度器介绍 1 简介 这几天在学习Go的GPM机制 于是就整理了一下收集的资料分享给大家 文章末尾有原文链接 主要介绍了Go在运行时调度器的基本实现逻辑和演变过程 2 什么是Go调度器 Go调度器很轻量也很简单 足以撑起gor
  • ☀️光学会自动化测试还不够?还差最后这一步!☀️

    同大多数项目一样 自动化测试项目也需要一个完整的项目管理流程 在项目执行之前要进行充分的评估和计划 项目执行过程中要把控每个节点的质量 执行后要进行复盘和评估 确保项目顺利实施 并达到预期效果 01 自动化项目启动 在项目启动阶段 我们要明
  • cmd 字符串拼接

    在 Windows 系统的 cmd 或 PowerShell 中 可以使用 来拼接字符串 例如 echo 我的名字是 amp echo 小明
  • 10 个实用功能告诉你,谷歌云(Google Cloud)相对亚马逊云(AWS)有哪些优势?...

    来源 itnext 编译 武明利 责编 Carol 出品 CSDN云计算 ID CSDNcloud 有很多文章将谷歌云提供商 GCP 与亚马逊云服务 AWS 进行比较 但这篇文章并不想要做比较 作者主要是一个AWS用户 但最近一直使用GCP
  • LeetCode198.打家劫舍(动态规划)

    题目描述 来自LeetCode 思路 这道题和01背包很像 这件房屋偷不偷跟前一间房屋是否偷了有关 比如说这是第i间房屋 如果第i 1间房屋偷了 那第i间房屋就不能再偷 那最大值就跟前i 1间房屋的金额最大值有关 如果第i 1间房屋没偷 那
  • hp linux 禁用u盘启动,BIOS关闭Secure Boot(安全启动)方法大全(联想,华硕,DELL,HP等品牌)...

    在预装win10系统的电脑上BIOS中安全启动Secure Boot是默认开启的 如果你要安装其他系统 如Win7 Linux等系统那么需要关闭才可以 不然会无启动 这小编整理了联想 华硕 DELL HP等品牌关闭Secure Boot 安
  • 斗罗大陆解算法—魂环的最佳获取法

    前言 作者主页 雪碧有白泡泡 个人网站 雪碧的个人网站 推荐专栏 java一站式服务 前端炫酷代码分享 uniapp 从构建到提升 从0到英雄 vue成神之路 解决算法 一个专栏就够了 架构咱们从0说 数据流通的精妙之道 文章目录 前言 背
  • 关于kettle的一些使用笔记

    Kettle是一款国外开源的ETL工具 纯java编写 对于办公自动化来说也是一款神器 好了直入主题 这里只记录了kettle的一些常用的转换的组件作用和意义 并不含软件安装和使用过程 因为这个过程很简单 界面很友好 可以自己摸索 vers
  • Android9.0 iptables用INetd实现ip白名单的实现

    1 前言 在9 0的系统rom定制化开发中 在system中netd网络这块的产品需要中 会要求设置屏蔽ip地址之内的功能 liunx中iptables命令也是比较重要的 接下来就来在INetd这块实现ip白名单的的相关功能 就是在app中
  • 理解Linux下的进程和程序,分析fork、execve和进程切换

    本次实验从整体上理解进程创建 可执行文件的加载和进程执行进程切换 重点理解分析fork execve和进程切换 一 理解task struct数据结构 进程是处于执行期的程序以及它所管理的资源 如打开的文件 挂起的信号 进程状态 地址空间等
  • 经理人必看的十个管理网站

    经理人必看的十个管理网站 管理这玩艺远远看着如同象牙塔中的佛牙舍利 可观而不可玩 其实身在其中无非就是一张窗户纸 没有什么大不了的 管理这玩艺远远看着如同象牙塔中的佛牙舍利 可观而不可玩 其实身在其中无非就是一张窗户纸 没有什么大不了的 网
  • C# NPOI写excel文件,设置某个单元格为自动筛选

    https blog csdn net qq 40467670 article details 118102078 如标题所示 附上几行代码 HSSFWorkbook workbook new HSSFWorkbook 创建工作表 var
  • Uva 10474 Where is the Marble?(排序与检索)

    本题若掌握了sort 和lower bound 两个函数 就无难点 include
  • 通关6级之词汇(2021.05.29)

    前言 这篇词汇是通关6级系列第一篇文章 这篇文章和4级有大部分内容是一样的 所以如果学了4级的课程再学这个会很轻松 更多相关文章点击阅读 通关4级之阅读理解 通关4级之听力 通关4级之写作 通关4级之翻译 通关4级之词汇 通关6级之词汇 点
  • STM32 ST-LINK Utility程序烧录方法

    打开软件过后点击Target connect 出现以下界面表示STlink链接成功 如果出现没有检测到stlink的话 首先查看是否安装驱动程序 再重新插拔电脑usb口的stlink连接线 或者链接到主机后方的usb口 再重复以上步骤链接
  • Fire Net

    点击打开链接 Problem Description Suppose that we have a square city with straight streets A map of a city is a square board wi
  • 利用python对b站某GPT-4解说视频的近万条弹幕进行爬取、数据挖掘、数据分析、弹幕数量预测及情绪分类

    目录 一 利用Python爬取弹幕 二 利用几行代码直接生成词云 三 将弹幕属性和内容放入mysql当中 四 分析弹幕在视频各节点的数量 1 分析视频各个片段出现的弹幕数量 2 分析视频各大章节出现的弹幕数量 3 分析视频各小节出现的弹幕数
  • Learning Java language Fundamentals

    Chapter 2 Learning Java language fundamentals exercises 1 What is Unicode Unicode is a computing industry standard for c