当前位置:首页 > 全部子站 > IT > 思科认证

格林模拟试题三参考答案(1)

来源:长理培训发布时间:2017-12-19 10:53:29

 answers

answer to question 1)

1) float f=1/3;
4) double d=999d;

the fact that option 3 does not compile may be a surprise. the problem is because the default type for a number with a decimal component is a double and not a float. the additional trailing d in the option with 999 doesn't help, but it doesn't harm.

answer to question 2)

2) new

the option null (note the upper case letter) is definitely not a keyword. there is some discussion as to i. there is some discussion as to if null is a keyword but for the purpose of the exam you should probably assume it is a keyword.

the option instanceof is a bit of a misleading option that would probably not occur on the exam. the real keyword is instanceof (note that the of has no capital letter o). i had the incorrect version in an earlier version of this tutorial as it looks more likely to my eyes. the instanceof keyword looks like a method, but it is actually an operator.

the option wend is probably valid in some other language to indicate the end of awhile loop, but java has no such keyword.

answer to question 3)

1) system.out.println(1+1);
option 3 is not valid because single quotes are used to indicate a character constant and not a string. several people have emailed me to say that option 3 will compile. when they eventually compiled the exact code they have agreed, it will not compile. let me re-state that

string s="on"+'one';

will not compile.

option 4 will not compile because 255 is out of the range of a byte

answer to question 4)

1) the garbage collection algorithm in java is vendor implemented

threading and garbage collection are two of the few areas that are platform dependent. this is one of the
plane or nuclear power station. once an instance of the integer class has a value it cannot be changed.

answer to question 5)

(not on the official sub objectives but this topic does come up on the exam)

2) the randomaccessfile class allows you to move directly to any point a file.

the file class can be considered to represent information about a file rather than a real file object. you can create a file in the underlying operating system by passing an instance of a file to a stream such as fileoutputstream. the file will be created when you call the close method of the stream. |||

answer to question 6)

2) the instanceof operator can be used to determine if a reference is an instance of a particular primitive wrapper classthe instanceof operator can only be used to make a static comparison with a class type. java1.1 added the isinstance method to the class class to allow you to dynamically determine a class type. the exam does not test you on isinstance.

answer to question 7)

2) interfaces cannot have constructors

if you try to create a constructor for an interface the compiler will give you an error message something like

"interface can't have constructors".

4) interfaces are the java approach to addressing the single inheritance model, but require implementing classes to create the functionality of the interfaces.

an interface may contain variables as well as methods. however any variables are final by default and must be assigned values on creation. a class can only extend one other class (single inheritance) but may implement as many interfaces as you like (or is sensible).

 

answer to question 8)

none of these are valid statements. the math class is final and cannot be extended. the max method takes two parameters, round only takes one parameter and there is no mod parameter. you may get questions in the exam that have no apparently correct answer. if you are absolutely sure this is the case, do not check any of the options.

 

 

answer to question 9)

1) the runnable interface has only one method run that needs to be created in any class that implements it. the start method is used to actually call and start the run method executing.

answer to question 10)

1) a byte can represent between -128 to 127

the char type is the only unsigned type in java and thus cannot represent a negative number.

for more information on this topic go to

answer to question 11)

2) compilation and no output at runtime

because the method in base called base has a return type it is not a constructor and there for does not get called on creation of an instance of its child class in

for more information on this topic go to

answer to question 12)

4) compilation and output of hello

this type of question is particularly calculated to catch out c/c++ programmers who might expect parameter zero to be the name of the compiler.

for more information on this topic go to

|||

answer to question 13)

1) if a class has any abstract methods it must be declared abstract itself.
4) transient and volatile are java modifiers

an abstract class may have non abstract methods. any class that descends from anabstract class must implement the abstract methods of the base class or declare them as abstract itself.

for more information on this topic go to

answer to question 14)

2) public static void amethod(){}

option 1 is not valid because it has braces and the native modifier means that the method can have no body. this is because the body must be implemented in some other language (often c/c++). option 3 is not valid because private and protected contradict themselves.

for more information on this topic go to

 

answer to question 15)

4) constructors are not inherited

constructors can be marked public, private or protected. constructors do not have a return type.

for more information on this topic go to

 

责编:罗莉

发表评论(共0条评论)
请自觉遵守互联网相关政策法规,评论内容只代表网友观点,发表审核后显示!

国家电网校园招聘考试直播课程通关班

  • 讲师:刘萍萍 / 谢楠
  • 课时:160h
  • 价格 4580

特色双名师解密新课程高频考点,送国家电网教材讲义,助力一次通关

配套通关班送国网在线题库一套

课程专业名称
讲师
课时
查看课程

国家电网招聘考试录播视频课程

  • 讲师:崔莹莹 / 刘萍萍
  • 课时:180h
  • 价格 3580

特色解密新课程高频考点,免费学习,助力一次通关

配套全套国网视频课程免费学习

课程专业名称
讲师
课时
查看课程
在线题库
面授课程更多>>
图书商城更多>>
在线报名
  • 报考专业:
    *(必填)
  • 姓名:
    *(必填)
  • 手机号码:
    *(必填)
返回顶部