- 浏览: 120348 次
- 性别:
- 来自: 武汉
文章分类
最新评论
-
Odysseus_110:
terryang 写道lz加上时间也不太合适,刷新太快的话还是 ...
$.getJSON 缓存 -
ll.james:
5楼的,真管用通知公告模块A.通知公告的类型没有实现控制B.通 ...
$.getJSON 缓存 -
zranye:
这样虽然能启动,但是会出现乱码
resin 无法启动 com.caucho.config.LineConfigException: -
酒杯中的大海:
学习了!!!~
struts 文件上传 乱码 -
酒杯中的大海:
牛逼,膜拜~
struts 文件上传 乱码
The default constructor has the same access as its class
which gets the name of the parent directory file “file.txt”?
String name = (new File(“file.txt”)).getParent();
which of these are valid JavaBeans method signatures?
A public void removeWibbleListener(BurbleListener w)
B public void addElement(Element e)
C public boolean getActive()
D public boolean isActive()
E int getFooNumber()
F public long size()
The correct options are C and D.With regards to the JavaBeans naming conventions:
E is incorrect because getter and setter methods must be public
B is incorrect because an add… or remove… method must end in ….Listener
A is incorrect because a removeWibbleListener method must take a WibbleListener as its argument
which methods can be declared at the position indicated and not cause a compile-time error?
A protected void drawSting()
B void drawSting();
C public abstract void drawSting();
D public static void drawSting();
E strictfp void drawSting();
The correct options are B and C
Interface method declarations are implicitly public and abstract,and these modifiers can be omitted.Interface methods cannot be static(ruling out D),nor can they be marked strictfp(ruling out E) ,final or native.Marking A protected conflicts with the restriction that interface methods must be public.
Fill in the table to indicate which Exception and Error classes are typically thrown programmatically and which by the JVM.
Exception/Error class Typically thrown…?
ArrayIndexOutOfBoundsException By the JVM
ClassCastException By the JVM
IllegalArgumentException Programatically
IllegalStateException Programatically
NullPointerException By the JVM
NumberFormatException Programatically
AssertionError Programatically
ExceptionInInitalizerError By the JVM
StackOverflowError By the JVM
NoClassDefFoundError By the JVM
How many lines don't compile ?
byte a = 127 + 1 ;
byte b = ( byte ) 25768 ;
char c = 127 ;
c+= 12345 ;
Answer: line 1 does not compile
127 is the max value of a byte. Casting makes everything ok. Remember += does an automatic cast.
class test { public static void main ( String [] args ) { final Integer x4 = 8; final int x = 10; switch ( x ) { case x4: System.out.println("4"); break; case x: System.out.println("x"); break; } } }
compile error
Final objects are not allowed in a case statement. A final object's value can be changed whereas a final variables value cannot be changed.
an interface may extend multiple interfaces
an ArithmeticException is a checked exception.
Answer:false
ArithmeticException are considered programmer problems ,and are Not checked by the compiler.A divide-by-zero error,for example,should be checked for by your own code.
Public class Demo{ public static void main(String[] args){ for(int i =0;i < 3;i++){ label1: switch(i){ case 0: System.out.println(“34”); case 1: System.out,println(“23”); break; case 2: System.out.println(“12”); case 3: System.out.println(“01”); break label1; default: System.out.println(“40”); } } } }
A The code is correct and it compiles.
label1: can lay before switch?
you can put label before any statement or block of code.
but you cannot call break labelX if you are not in its scope.
you are trying to call break label1 in switch case 3 but it is out of scope.
look this code about scopes:
label1: System.out.println("in label1");//here scope of this label is //this one statement so you can't //break label2:{ //here starts scope of label2 System.out.println("label 2 started"); break label2; // here you can use break in scope of this label System.out.println("label 2 ended"); //but it wont compile because compiler //knows this statement is unreachable } //here ends scope of label2 break label2; // you cant do this here because you are out of scope for(int i = 0; i < 5; i++){ // bla bla bla break label2; // you cant do this here because you are out of scope
which of these are legal escape sequences?
A \n
B \f
C \m
D \n
E \e
F \r
G \t
ABDFG
Remember the sentence:”Big farms need red tractors ”
only “b” “f” “n” “r” and “t” are legal,no other characters!
Which of the following statements are not true?
java.lang.Character does not extend java.lang.Number
java.lang.Void can't be extended but it can only be instantiated
java.lang.Integer can't be extended
java.lang.Character does not have a constructor that takes a String
java.lang.Byte does not extend java.lang.Number
B and E are correct. Only these two statements are NOT true. The class java.lang.Void is an uninstantiable placeholder class to hold a reference to the Class object representing the Java keyword void. This class is final and has a private constructor. Hence, it can neither be extended nor can it be instantiated.
The class java.lang.Byte does indeed extend java.lang.Number.
The class java.lang.Character does not extend java.lang.Number, and has only one constructor that takes a char value.
All wrapper classes are final, and hence they can not be extended.
It is perfectly legal in Java to create arrays of size zero.
在定义一个
native method
时,并不提供实现体(有些像定义一个
java interface
),因为其实现体是由非
java
语言在外面实现的。,下面给了一个示例:
public class IHaveNatives
{
native public void Native1( int x ) ;
native static public long Native2() ;
native synchronized private float Native3( Object o ) ;
native void Native4( int[] ary ) throws Exception ;
}
标识符 native 可以与所有其它的 java 标识符连用,但是 abstract 除外。这是合理的,因为 native 暗示这些方法是有实现体的,只不过这些实现体是非 java 的,但是 abstract 却显然的指明这些方法无实现体。
What will happen when you attempt to compile and run the following code?
class MyClass { static String myName = "SCJP"; MyClass getMyClass() { System.out.println(myName); return null; } public static void main(String[ ] args) { System.out.println( new MyClass().getMyClass().myName ); } }
Answer: Prints SCJP twice
C is the correct choice. The above method will not give any compilation error as at compile time, compiler sees the return type of getMyClass method as MyClass and calling myName on MyClass is valid at compile time.
Also it doesn't give any runtime error which is not very obvious. Please note that a null reference may be used to access a class (static) variable without causing an exception . The static variable is called on the class itself and not on the object. Had the myName variable non-static, the above code at run time would give NullPointerException.
- scjpnote.rar (283 KB)
- 描述: scjp学习笔记
- 下载次数: 8
发表评论
-
ant 正则表达式 换行符
2011-02-05 23:05 3076SSH上传文件的时候 报错 无法上传文件 可能是因为存在本地 ... -
ftp 文件上传 无法上传中文名称
2009-08-12 14:11 2242代码参考上一篇《ftp文件上传 文件损坏》 ... -
ftp 文件上传 文件损坏
2009-08-12 13:35 2801这里演示的是配置好ftp服务器后,通过java ... -
SCJP 5.0 Study Notes(3)
2009-07-03 22:11 848Enums <!---->· &l ... -
SCJP 5.0 Study Notes(2)
2009-07-03 21:48 945Encapsulation, coupling, cohesi ... -
C语言
2008-09-01 08:23 0(1)指针变量初始化的方法 int a;int *p=& ... -
tomcat
2008-07-08 17:38 0<Context crossContex ... -
SCJP 5.0 Study Notes(1)
2008-07-01 08:59 1038Note: Please feel free to mo ... -
Computer Science
2008-06-03 15:55 1278中文名称 :计算机科学 ... -
Integer中用静态内部类所作的缓存
2008-05-22 20:49 1530今天在做一个题目时,发现一个奇怪的Integer方法。 pub ... -
图片切割的研究
2008-05-15 14:35 0切割图片 -
SCJP tips
2008-05-09 10:21 12171. Thread t1 = new Thread(&quo ...
相关推荐
CPPC++_低成本实现Wooting键盘的Rapid trigger功能不必为几个按键购买整个键盘人人都能做Wouo
CPPC++_可能是世界上最快的协同程序库
ConsulHelper,.Net微服务基础框架,已支持.NetCore,具备服务发现、健康检查、服务分级、分布式配置、版本控制
有卫星、警车、消防车、Cesium飞机、Cesium无人机等等。具体图片如下文章:https://blog.csdn.net/weixin_44857463/article/details/143721670?sharetype=blogdetail&sharerId=143721670&sharerefer=PC&sharesource=weixin_44857463&spm=1011.2480.3001.8118
yii2.0+admin后台以及rbac权限
SpringBlade3.0架构核心工具包,SpringBlade是一个由商业级项目升级优化而来的SpringCloud分布
python各种项目代码
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
Apache Flink:Flink状态与容错机制.docx
CPPC++_更好的渲染龙
Commuter welfare and green commute share optimization
Amazon S3:S3智能分层存储教程.docx
LINDO和LINGO教程
CPPC++_实时语音识别和语音活动检测VAD使用nextgen Kaldi与ncnn无互联网连接支持iOS Andr
cppc++
10020
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。 替换数据可以直接使用,注释清楚,适合新手
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
Matlab领域上传的视频均有对应的完整代码,皆可运行,亲测可用,适合小白; 1、代码压缩包内容 主函数:main.m; 调用函数:其他m文件;无需运行 运行结果效果图; 2、代码运行版本 Matlab 2019b;若运行有误,根据提示修改;若不会,私信博主; 3、运行操作步骤 步骤一:将所有文件放到Matlab的当前文件夹中; 步骤二:双击打开main.m文件; 步骤三:点击运行,等程序运行完得到结果; 4、仿真咨询 如需其他服务,可私信博主; 4.1 博客或资源的完整代码提供 4.2 期刊或参考文献复现 4.3 Matlab程序定制 4.4 科研合作
cppc++