java小问题,请懂java的帮帮忙做一下
下面程序的输出结果是什么?()classsreejith{Strings;publicstaticvoidmain(Stringargs[]){sreejithks=ne...
下面程序的输出结果是什么?( )
class sreejith
{
String s;
public static void main(String args[])
{
sreejith ks=new sreejith();
int j,i;
i=ks.hai();
j=ks.hello();
System.out.println(i+" "+j);
}
int hai()
{
if (s = = null)|| (s.length() = = 0))
return 10;
else return 0;
}
int hello()
{
if (s = = null) | (s.length() = = 20))
return 10;
else return 0;
}
}
A 0 0
B 10 10
C An Exception in hai
D An Exception in hello
当一个新的线程开始执行时,它会调用哪一个方法作为这个线程运行的开始方法?
A public void sleep()
B public void run()
C public void start()
D public static void main(String args[])
下列那个表达式为true( )
A、"hello:there!".equals("hello there")
B、"HELLO THERE".equalsIgnoreCase("hello there")
C、("hello".concat("there")).equal("hello there")
D、 "Hello there".toUpperCase().equals("hello there")
下列代码执行的结果是?
Public class text {
public static void main(String[] args) {
int x= 1, y = 6;
while (y-- = =6) {x--;}
System.out.println("x=" + x +" ,y =" + y);
}
}
A) 程序能运行,输出结果:x=0,y=4
B) 程序能运行,输出结果:x=-1,y=4
C) 程序能运行,输出结果:x=0,y=5
D) 程序不能编译
下面程序的输出结果是什么?( )
public static void main(String args[])
{
int a=20;
int b=20;
if(a = = b)
System.out.println("Not Equal is error");
else
System.out.println("Equal right");
}
A Equal right
B Not Equal is error
C 编译错误
D 运行时将抛出异常
在服务器端,ServerSocket使用什么方法监听来自客户的通信?( )
A get()
B accept()
C getClient()
D acceptClient()
在网络通信中,Socket使用什么协议来通信?( B )
A TCP
B UDP
C NetBeui
D AppleTalk
. 在线程通信过程中,Java可以使用什么关键字来避免出来冲突?( B )
A Lock
B Synchronized
C Synclock
D belock 展开
class sreejith
{
String s;
public static void main(String args[])
{
sreejith ks=new sreejith();
int j,i;
i=ks.hai();
j=ks.hello();
System.out.println(i+" "+j);
}
int hai()
{
if (s = = null)|| (s.length() = = 0))
return 10;
else return 0;
}
int hello()
{
if (s = = null) | (s.length() = = 20))
return 10;
else return 0;
}
}
A 0 0
B 10 10
C An Exception in hai
D An Exception in hello
当一个新的线程开始执行时,它会调用哪一个方法作为这个线程运行的开始方法?
A public void sleep()
B public void run()
C public void start()
D public static void main(String args[])
下列那个表达式为true( )
A、"hello:there!".equals("hello there")
B、"HELLO THERE".equalsIgnoreCase("hello there")
C、("hello".concat("there")).equal("hello there")
D、 "Hello there".toUpperCase().equals("hello there")
下列代码执行的结果是?
Public class text {
public static void main(String[] args) {
int x= 1, y = 6;
while (y-- = =6) {x--;}
System.out.println("x=" + x +" ,y =" + y);
}
}
A) 程序能运行,输出结果:x=0,y=4
B) 程序能运行,输出结果:x=-1,y=4
C) 程序能运行,输出结果:x=0,y=5
D) 程序不能编译
下面程序的输出结果是什么?( )
public static void main(String args[])
{
int a=20;
int b=20;
if(a = = b)
System.out.println("Not Equal is error");
else
System.out.println("Equal right");
}
A Equal right
B Not Equal is error
C 编译错误
D 运行时将抛出异常
在服务器端,ServerSocket使用什么方法监听来自客户的通信?( )
A get()
B accept()
C getClient()
D acceptClient()
在网络通信中,Socket使用什么协议来通信?( B )
A TCP
B UDP
C NetBeui
D AppleTalk
. 在线程通信过程中,Java可以使用什么关键字来避免出来冲突?( B )
A Lock
B Synchronized
C Synclock
D belock 展开
2个回答
展开全部
1:D,s没初始化吧
2:C,这个是基本
3:B,equalsIgnoreCase()这个方法是无视大小写比较String类型
4:A,y-- == 6是先执行y == 6,然后执行y = y - 1,while条件判断了两次
5:这个我觉得是C吧,因为代码本身没错,只不过这是一个类的主方法所以要放在类中执行,单独不能运行吧
6,7我不太懂,不敢乱回答
2:C,这个是基本
3:B,equalsIgnoreCase()这个方法是无视大小写比较String类型
4:A,y-- == 6是先执行y == 6,然后执行y = y - 1,while条件判断了两次
5:这个我觉得是C吧,因为代码本身没错,只不过这是一个类的主方法所以要放在类中执行,单独不能运行吧
6,7我不太懂,不敢乱回答
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询