image

编辑人: 浅唱

calendar2025-05-20

message6

visits522

携程笔试题(内部)

一、 JAVA基础知识(每题2分,共20分)

1.下列语句序列执行后,k 的值是 ( )。

int m=3, n=6, k=0; while( (m++) < ( — n) ) ++k;

A. 0 B. 1 C. 2 D. 3

2 **.**设 i、j 为int型变量名,a 为int型数组名,以下选项中,正确的赋值语句是( )。

A. i = i + 2 B. a[0] = 7; C. i++ – –j; D. a(0) = 66;

3 **.**Java语言的类间的继承关系是( )。

A. 多重的 B. 单重的 C. 线程的 D. 不能继承

4 **.**设有定义 int i = 6 ;,则执行以下语句后,i 的值为( )。

i += i – 1;

A. 10 B. 121 C. 11 D. 100

5.下列选项中,用于在定义子类时声明父类名的关键字是( )。

A)interface B. package C. extends D. class

6 **.**若已定义 byte[ ] x= {11,22,33,-66} ; 其中0≤k≤3,则对x数组元素错误的引用是( )。

A. x[5-3] B. x[k] C. x[k+5] D. x[0]

7 **.**下列语句序列执行后,ch1 的值是( )。

char ch1=‘A’,ch2=‘W’; if(ch1 + 2 < ch2 ) ++ch1;

A. ‘A’ B. ‘B’ C. ‘C’ D. B

8 **.**下列语句序列执行后,i 的值是( )。

int i=8, j=16; if( i-1 > j ) i–; else j–;

A. 15 B. 16 C. 7 D. 8

9 **.**下列语句序列执行后,k 的值是( )。

int i=10, j=18, k=30;

switch( j – i ) { case 8 : k++; case 9 : k+=2; case 10: k+=3; default : k/=j; }

A. 31 B. 32 C. 2 D. 33

10.下面语句执行后,i 的值是( )。

for( int i=0, j=1; j < 5; j+=3 ) i=i+j;

4 B. 5 C. 6 D. 7

二、 JAVAScript基础知识(每题2分,共计10分)

**1.**在JavaScript中,命令按纽(Button)支持的事件包括( )

  1. onClick onChange C. onSelect D. onSubmit
  2. 在JavaScript中,可以使用Date对象的( )方法返回该对象 的日期
  3. getDate getMonth C. getYear D. getTime
  4. 哪一个对象可以获得屏幕的大小( )
  5. window screen C. navigator D. screenX
  6. setInterval(“alert(‘welcome’);”,1000);这段代码的意思是( )
  7. 等待1000秒后,再弹出一个对话框
  8. 等待1秒钟后弹出一个对话框
  9. 语句报错,语法有问题
  10. 每隔一秒钟弹出一个对话框
  11. window对象的open方法返回的是( )
  12. 没有返回值
  13. boolean类型,表示当前窗口是否打开成功
  14. 返回打开新窗口的对象

D.返回int类型的值 ,开启窗口的个数

三、 数据库知识(每题2分,共计20分)

  1. 数据库系统的核心是____。

A.数据库 B.数据库管理系统 C.数据模型 D.软件工具

  1. SQL语言具有____的功能。
  • 关系规范化、数据操纵、数据控制
  • 数据定义、数据操纵、数据控制
  • 数据定义、关系规范化、数据控制
  • 数据定义、关系规范化、数据操纵
  1. SQL语言的数据操纵语句包括 SELECT,INSERT,UPDATE和 DELETE,最重要的,也是使用最频繁的语句是____。

A.SELECT B.INSERT C.UPDATE D.DELETE

  1. 在关系数据库设计中,设计关系模式是____的任务。
  • 需求分析阶段 B.概念设计阶段 C.逻辑设计阶段 D.物理设计阶段
  1. ____是DBMS的基本单位,它是用户定义的一组逻辑一致的程序序列。

A.程序 B.命令 C.事务 D.文件

  1. 下列SQL语句中,创建关系表的是____。

A.ALTER B.CREATE C.UPDATE D.INSERT

  1. 数据库的____是为了保证由授权用户对数据库所做的修改不会影响数据一致性的损失。

A.安全性 B.完整性 C.并发控制 D.恢复

  1. 数据库进行的基本工作单位。如果一个事务执行成功,则全部更新提交;如果一个事务执行失败,则已做过的更新被恢复原状,好像整个事务从未有过这些更新,这样保持了数据库处于________状态。

A.安全性 B.一致性 C.完整性 D.可靠性

  1. 对并发操作若不加以控制,可能会带来数据的____问题。

A.不安全 B.死锁 C.死机 D.不一致

  1. 已知表T1中有2行数据,T2中有3行数据,执行SQL语句

"select a.* from T1 a,T2 b"后,返回的行数为______

A、2行 B、3行 C、5行 D、6行

四、 逻辑推理(每题2分,共计10分)

(略)

五、 算法题(40分)

  • 基础编程(每题5 分,共计10 分)
  1. 写出一个Singleton的示例代码

  2. 利用递归算法求n! (n为一整型值,并且0<=n<10)。

  • 算法题(每题15 分,共计30 分)(写出详细思路即可,不用写具体答案)
  1. ShippingCubes

Problem Statement

You want to ship N cubes abroad. The size of each cube is 1 x 1 x 1. You can only ship the cubes by filling them into a single cuboid box. The cost of shipping a cuboid box with dimensions a x b x c is equal to (a+b+c).

You can’t leave any empty space in the box, because the cubes would shift and get damaged during the transfer.

You are given an int N. Return the minimal cost of shipping N cubes.

Definition

Class: ShippingCubes

Method: minimalCost

Parameters: int

Returns: int

Method signature: int minimalCost(int N)

(be sure your method is public)

Constraints

N will be between 1 and 200, inclusive.

Examples

0) 1

Returns: 3

The only way is to use a box with dimensions 1 x 1 x 1.

1) 6

Returns: 6

This time one optimal solution is to send a box with dimensions 1 x 2 x 3. The cost of sending this box is 1+2+3 = 6. Any other option is at least as expensive as this one. For example, sending a box with dimensions 6 x 1 x 1 has the cost 6+1+1 = 8.

2) 7

Returns: 9

3) 200

Returns: 18

  1. ColorfulStrings

Problem Statement

The product value of a string is the product of all the digits (‘0’-‘9’) in the string. For example, the product value of “123” is 1 * 2 * 3 = 6.

A string is called colorful if it contains only digits and the product value of each of its nonempty contiguous substrings is distinct.

For example, the string “263” has six substrings: “2”, “6”, “3”, “26”, “63” and “263”. The product values of these substrings are: 2, 6, 3, 2 * 6 = 12, 6 * 3 = 18 and 2 * 6 * 3 = 36, respectively. Since all six product values are distinct, “263” is colorful.

On the other hand, “236” is not colorful because two of its substrings, “6” and “23”, have the same product value (6 = 2 * 3).

Return the k-th (1-based) lexicographically smallest colorful string of length n. If there are less than k colorful strings of length n, return an empty String instead.

Definition

Class: ColorfulStrings

Method: getKth

Parameters: int, int

Returns: String

Method signature: String getKth(int n, int k)

(be sure your method is public)

Notes

  • The lexicographically smaller of two strings is the one that has the smaller character (‘0’ < ‘1’ < … < ‘9’) at the first position where they differ.

Constraints

  • n will be between 1 and 50, inclusive.
  • k will be between 1 and 1,000,000,000, inclusive.

Examples

0) 3

4

Returns: “238”

The first four smallest colorful strings of length 3 are “234”, “235”, “237” and “238”.

1) 4

2000

Returns: ""

The number of colorful strings of length 4 is less than 2000.

2) 5

1

Returns: “23457”

3) 2

22

Returns: “52”

4) 6

464

Returns: “257936”



喵呜刷题:让学习像火箭一样快速,快来微信扫码,体验免费刷题服务,开启你的学习加速器!

创作类型:
原创

本文链接:携程笔试题(内部)

版权声明:本站点所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明文章出处。
分享文章
share