哔哩哔哩2020校园招聘技术类笔试卷(二)

1. 关于canvas和svg说法正确的是?(C

A. canvas支持事件处理器
B. canvas不依赖分辨率,缩放不失真
C. svg不依赖分辨率,缩放不失真
D. svg适合图像密集型的游戏

解析:
在这里插入图片描述

2. a标签的href和onclick属性同时存在时哪个先触发?(B

A. href先执行
B. onclick先执行
C. 同时执行
D. 只执行href

解析:
可以通过onclick的函数中,设置return false;阻止默认的点击跳转事件;

3. 以下关于跨域说法错误的是?(D

A. Cookie,LocalStorage和IndexedDB都会受到同源策略的限制
B. postMessage,JSONP,WebSocket都是常用的解决跨域的方案
C. 跨域资源共享规范中规定了除了GET之外的HTTP请求,或者搭配某些MINE类型的POST请求,浏览器都需要先发一个OPTIONS请求
D. http://www.bilibili.com和https://www.bilibili.com是相同的域名,属于同源

解析:
http 80端口
https 443端口
在这里插入图片描述

4. 下列资源加载顺序哪种是不可能的出现的?(C

在这里插入图片描述
A. d.css, b.css, c.js, a.js
B. b.css, d.css, c.js, a.js
C. a.js, b.css, c.js, d.css
D. c.js, d.css, b.css, a.js

解析:
prefetch是告诉浏览器加载下一页可能会用到的资源,是下一页面不是当前页面,所以prefetch优先级非常低,该方式的作用是加速下一个页面的加载速度,因此a.js应该是最后一个。

  • preload是在页面加载的生命周期的早期阶段就开始获取
  • prefetch是预加载
  • stylesheet是声明此文件为样式表文件
5. 选择语义与其他三项明显不同的标签(C

A. <aside>
B. <footer>
C. <area>
D. <summary>

解析:
<area> 标签定义图像映射中的区域(注:图像映射指得是带有可点击区域的图像)。
<summary> 标签包含 details 元素的标题,“details” 元素用于描述有关文档或文档片段的详细信息。
<footer> 标签定义文档或节的页脚。元素应当含有其包含元素的信息。
页脚通常包含文档的作者、版权信息、使用条款链接、联系信息等等。
<aside> 标签定义其所处内容之外的内容。

6. CSS中不支持样式子元素继承的是?(C

A. font-size
B. color
C. margin
D. cursor

解析:
css-可继承和不可继承的属性:https://blog.csdn.net/github_34514750/article/details/52554511

7. 样式权重的优先级下面正确的是?(A

A. !important > 行内样式(style) > id > class > tag
B. 行内样式(style) > !important > id > tag > class
C. id > 行内样式(style) > !important > class > tag
D. id > !important > 行内样式(style) > tag > class

解析:
css的优先级 和 权重:https://www.cnblogs.com/cnblogs-jcy/p/8574177.html

8. 根据下面代码所述,点击 area ,box 高度的表现是?(D

A. 高度保持 100 不变
B. 高度保持 0 不变
C. 高度从 0 渐变为 100
D. 高度从 0 瞬变为 100

解析:
transition要配合:hover使用 没有:hover所以可以忽略transition 点击area后 给box设置高度100

9. 关于页面重绘和回流说法错误的是?(B

A. 添加和删除元素会触发页面回流和重绘
B. 对 style 的操作改变color、background-color会回流,改变padding、margin会重绘
C. display:none 隐藏元素会触发页面回流和重绘
D. 浏览器大小改变resize、font-size会触发页面回流和重绘

解析:
什么是回流,什么是重绘,有什么区别?
参考链接:https://www.jianshu.com/p/e081f9aa03fb

10. 数组以下哪个方法会影响原数组?(B

A. concat
B. splice
C. slice
D. join

解析:
数组中的方法-- 会改变原数组的:https://www.cnblogs.com/buxiugangzi/p/12078993.html
改变数组:
var arr = []
arr.splice()
arr.reverse()
arr.fill()
arr.copyWithin()
arr.sort()
arr.push()
arr.pop()
arr.unshift()
arr.shift()
不改变数组:
var arr = []
arr.slice()
arr.map()
arr.forEach()
arr.every()
arr.some()
arr.filter()
arr.reduce()
arr.entries()
arr.find()
arr.concat(‘1’,[‘2’,‘3’]) //[1,2,3]

11. 下面关于节流和防抖说法正确的是?(D

A. 防抖是规定在一个单位时间内,只能触发一次函数
B. 节流在事件被触发n秒后再执行回调,如果在这n秒内又被触发,则重新计时
C. 节流函数的实现必须依赖于setTimeout来实现
D. 在做图片按需懒加载的场景里,我们一般用防抖的方式来优化加载图片

解析:
防抖和节流:https://blog.csdn.net/P6P7qsW6ua47A2Sb/article/details/88802146

12. 关于null和undefined下面输出错误的是?(C

A. +null 输出为 0
B. +undefined 输出为 NaN
C. JSON.stringify({a:undefined}) 输出为 {“a”:“undefined”}
D. JSON.stringify({a:null}) 输出为 {“a”:null}

解析:
非数组对象中,value是Undefined的属性会被忽略,所以JSON.stringify({a:undefined}) 输出{}

13. 下列代码的运行输出结果是?(D

在这里插入图片描述
A. {key: ‘b’}
B. {key: ‘c’}
C. b
D. c

解析:
var a = {},b={key:‘b’},c={key:‘c’}
a[b] = ‘b’
// a = {[object Object]: “b”}
a[c] = ‘c’
//a = {[object Object]: “c”}
a[b]
// “c”,实际打印的是a["[object Object]"]

14. -1 >> 32 的值为? (A

A. -1
B. 1
C. 0
D. 2^32-1

解析:
>> 有符号右移
>>>无符号右移
1 >>> 32 == 1
1L >>> 64 == 1
1 >>> 33 相当于右移一位
对于int类型,只有32位,右移32位等于右移0位
对于long类型,有64位,右移64位等于右移0位

15. [‘10’, ‘10’, ‘10’, ‘10’, ‘10’].map(parseInt);(D

A. [NaN, NaN, NaN, NaN]
B. [10, 10, 10, 10, 10]
C. [NaN, 2, 3, 4, 5]
D. [10, NaN, 2, 3, 4]

解析:
参考链接:https://blog.csdn.net/qq_37674616/article/details/87600711

16. 下列代码运行结果正确的是?(B

在这里插入图片描述
A. function
B. string
C. number
D. undefined

解析:
匿名函数自调,返回值给了fn

17. 下面代码运行结果正确的是?(B

在这里插入图片描述
A. 1 7 1
B. 6 7 1
C. 1 2 8
D. 6 7 8

解析:
引用类型的赋与地址,基本类型是复制文本

18. 下列代码的运行输出结果是? (A

在这里插入图片描述
A. 1 2 7 5 6 3
B. 7 1 2 5 6 3
C. 1 2 3 4 6 7
D. 1 2 7 4 6 3

解析:
Promise执行流程分析:https://blog.csdn.net/yonggeit/article/details/86518884

19. 下列代码的运行输出结果是? (D

在这里插入图片描述
A. 6
B. 30
C. 报错: Uncaught SyntaxError: Identifier ‘age’ has already been declared
D. 报错: Uncaught SyntaxError: Identifier ‘years’ has already been declared

解析:
var和let的区别:https://www.jianshu.com/p/84edd5cd93bd

20. 下列代码的运行输出结果是? (A

在这里插入图片描述
A.
“https%3A//www.bilibili.com/text.html”
“https://www.bilibili.com/text.html”
“https%3A%2F%2Fwww.bilibili.com%2Ftext.html”
B.
“https://www.bilibili.com/text.html”
“https%3A//www.bilibili.com/text.html”
“https%3A%2F%2Fwww.bilibili.com%2Ftext.html”
C.
“https%3A%2F%2Fwww.bilibili.com%2Ftext.html”
“https%3A//www.bilibili.com/text.html”
“https://www.bilibili.com/text.html”
D.
“https%3A//www.bilibili.com/text.html”
“https%3A%2F%2Fwww.bilibili.com%2Ftext.html”
“https://www.bilibili.com/text.html”

解析:
escape、encodeURI和encodeURIComponent的区别:https://www.cnblogs.com/qlqwjy/p/9934706.html

21. 输入两个表示复数的字符串,输出它们相乘的结果的字符串复数字符串用a+bi表示(a, b 为整数, i为虚数单位,i2=1)
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s1 = br.readLine();
        String s2 = br.readLine();
        
        int a;
        int b;
        int c;
        int d;
        String[] sp1 = s1.split("\\+");
        String[] sp2 = s2.split("\\+");
 
 
        boolean f1 = true;
        boolean f2 = true;
 
        if (sp1[1].contains("-")){
            sp1[1] = sp1[1].substring(1);
            f1 = false;
        }
 
        if (sp2[1].contains("-")){
            sp2[1] = sp2[1].substring(1);
            f2 = false;
        }
 
 
 
        if (sp1[1].length()!=1){
            b = Integer.parseInt(sp1[1].substring(0,sp1[1].lastIndexOf("i")));
        }else{
            b= 1;
        }
 
        if (sp2[1].length()!=1){
            d = Integer.parseInt(sp2[1].substring(0,sp2[1].lastIndexOf("i")));
        }else{
            d= 1;
        }
 
        a = Integer.parseInt(sp1[0]);
        c = Integer.parseInt(sp2[0]);
 
 
 
        System.out.println((a * c + b * d * (f2 == false ? -1 : 1) * (f1 == false ? -1 : 1) * -1 ==0?"0+": a * c + b * d * (f2 == false ? -1 : 1) * (f1 == false ? -1 : 1) * -1 + "+") + (a * d * (f2 == false ? -1 : 1) + b * c * (f1 == false ? -1 : 1)) + "i");
 
 
    }
 
}
22. 输入一个"YYYY-MM-dd"格式的日期字符串,输出该天是当年的第几天(1 月 1 日是每年的第 1 天)
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
 
public class Main {
    public static void main(String[] args) throws IOException {
 
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        String s1 = bufferedReader.readLine();
        String[] split = s1.split("-");
        Map map = new HashMap();
        map.put("01", 31);
        map.put("02-p", 28);
        map.put("02-r", 29);
        map.put("03", 31);
        map.put("04", 30);
        map.put("05", 31);
        map.put("06", 30);
        map.put("07", 31);
        map.put("08", 31);
        map.put("09", 30);
        map.put("10", 31);
        map.put("11", 30);
        map.put("12", 31);
 
        int year = Integer.parseInt(split[0]);
        int month = Integer.parseInt(split[1]);
        int day = Integer.parseInt(split[2]);
 
        if (month == 1){
            System.out.println(day);
        }else{
            int tot = 0;
            if((year%4==0&&year%100!=0)||(year%400==0)){
                for (int i = 1; i < month; i++) {
                    if (i==2){
                        tot += (Integer)map.get("0"+i+"-r");
                    }else{
                        tot += (Integer)map.get("0"+i);
                    }
                }
            }else{
                for (int i = 1; i < month; i++) {
                    if (i==2){
                        tot += (Integer)map.get("0"+i+"-p");
                    }else{
                        tot += (Integer)map.get("0"+i);
                    }
                }
            }
            System.out.println(tot + day);
        }
    }
 
}

23. 给你一个链表,每 k 个节点一组进行翻转,请返回翻转后的链表。

如果节点总数不是 k 的整数倍,那么请将最后剩余的节点保持原有顺序。

示例 :
给定这个链表:1->2->3->4->5
当 k = 2 时,应当返回: 2->1->4->3->5
当 k = 3 时,应当返回: 3->2->1->4->5

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
 
public class Main {
    public static void main(String[] args) throws IOException {
 
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        String s1 = bufferedReader.readLine();
        String s2 = bufferedReader.readLine();
 
        String[] split = s1.split(" ");
 
        List<String> res = new ArrayList<>();
        List<String> temp = new ArrayList<>();
        for (int i = 0; i < split.length-1; i++) {
            temp.add(split[i]);
            if ((i+1) % Integer.parseInt(s2) == 0){
                Collections.reverse(temp);
                res.addAll(temp);
                temp.clear();
            }
        }
        if (temp.size() > 0){
            res.addAll(temp);
        }
 
        String link = "";
 
        for (int i = 0; i < res.size(); i++) {
            if (i == res.size()-1){
                link += res.get(i);
            }else{
                link += res.get(i) + "->";
            }
        }
 
        System.out.println(link);
    }
}
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值