面试:java笔试题(1)

本文精选了若干面试笔试题目并提供了详细的解答,包括抽象类与接口的区别、不同进制的计算、字符串比较、代码输出结果解析、数组排序及整数到中文金额的转换等。

由于当时忘了拍个照,所以面完后只记得几题了,还有些不记得,因为内容太多不好记,所以就把印象深刻或者有疑问的记下。

以后面试的笔试题都记录在这。

接口和抽象类的区别

答:抽象类继承于object接口不继承;抽象类有构造器接口没有;抽象类中可以有抽象方法,也可以有普通方法,接口中只能有抽象的方法而且修饰符只能是public abstract不写默认;抽象类中可以有普通变量和常量,接口中只能有常量,而且只能是public static final不写默认;抽象类中可以有final的方法,接口中不能有final的方法;抽象类只能是单继承,多实现,接口是可以多继承其他接口,但是不能实现接口和不能继承其他类;抽象类中可以有静态的方法,接口中不可以。

78+78=132成立,结果是几进制表示的

答:11进制

以下代码的输出结果

String m = "12";
String s = new String("12");
System.out.println(m==s);
System.out.println(m.equals(s));

答:false  true

以下代码的输出结果

public class Null {
	static String str = new String("1233");
	static char[] cha = {'a','b','c'};
	
	public static void main(String[] args) {
		Null.test("hello",'m');
		System.out.println(Null.str+" and "+Null.cha);
	}
	
	public static void test(String a, char b) {
		str = a;
		cha[0] = b;
	}
}

答:hello and [C@7852e922

以下代码的输出结果:

public class Null {
	
	public static void test() {
		System.out.println("123");
	}
	
	public static void main(String[] args) {
		(Null(null)).test();
	}

}

答:编译异常

将下列数字排序1、3、8、2、4、9、19;

 int[] arrayInt = {1、3、8、2、4、9、1};
        for (int i = 0; i <= arrayInt.length - 1; i++) {
            for (int j = 0; j < arrayInt.length - 1; j++) {
                if (arrayInt[j] > arrayInt[j + 1]) {
                    int team = arrayInt[j];
                    arrayInt[j] = arrayInt[j + 1];
                    arrayInt[j + 1] = team;
                }
            }
        }
        for (int arr : arrayInt) {
            System.out.print(arr + " ");
        }

实现将整数转化为中文表示的金额,例如¥1011 = 壹仟零壹拾壹元整;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sunon_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值