mercyblitz / tech-daily-questions Goto Github PK
View Code? Open in Web Editor NEW「小马哥每日一问」
「小马哥每日一问」
public class Hamlet {
public static void main(String[] args) {
Random rnd = new Random();
boolean toBe = rnd.nextBoolean();
Number result = (toBe || !toBe) ?
new Integer(3) : new Float(1);
System.out.println(result);
}
}
以上程序输出内容是?
(a) 运行时异常
(b) 3
(c) 1.0
(d) 以上答案都不是
请小伙伴们在评论区直接作答,谢谢~
public class Parsing {
/**
* Returns Integer corresponding to s, or null if s is null.
* @throws NumberFormatException if s is nonnull and
* doesn't represent a valid integer
*/
public static Integer parseInt(String s) {
return (s == null) ?
(Integer) null : Integer.parseInt(s);
}
public static void main(String[] args) {
System.out.println(parseInt("-1") + " " +
parseInt(null) + " " +
parseInt("1"));
}
}
以上程序输出内容是?
(a) 运行时异常
(b) -1 null 1
(c) -1 0 1
(d) 编译错误
请小伙伴们在评论区直接作答,谢谢~
public class MyMap {
public static void main(String[] args) {
Map map = new IdentityHashMap<>();
map.put(1, "Hello");
map.putIfAbsent(1, "World");
print(map.get(1));
print(map.size());
map.put(1024, "A");
map.putIfAbsent(1024, "B");
print(map.get(1024));
print(map.size());
}
private static void print(Object object) {
System.out.print(object + " ");
}
}
以上程序输出内容是?
(a) Hello 1 null 3
(b) World 1 null 2
(c) Hello 2 null 2
(d) 以上答案都不是
请小伙伴们在评论区直接作答,谢谢~
public class IntegerChange {
public static void main(String[] args) throws Exception {
Integer a = Integer.parseInt("10");
Integer b = Integer.valueOf(10);
Integer c = 10;
changeValue(a, 100);
changeValue(b, 200);
changeValue(c, 300);
System.out.printf("%d %d %d", a, b, c);
}
private static void changeValue(Integer i, int value) throws Exception {
Field field = Integer.class.getDeclaredField("value");
field.setAccessible(true);
field.set(i, value);
}
}
以上程序输出内容是?
(a) 100 200 300
(b) 300 300 300
(c) 100 300 300
(d) 以上答案都不是
请小伙伴们在评论区直接作答,谢谢~
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.