帮助解决这些问题!! [英] help with these practice questions!!

查看:48
本文介绍了帮助解决这些问题!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

再次,

我从过去的试卷中解决了这些问题,对我的答案我并不完全自信。我希望你们能为我仔细检查一下。


这些是问题:


1-为了告诉系统如何执行,必须覆盖以下哪些方法线程?

(A)线程()
(B)执行()

(C)start()

(D)run()


2-以下哪项是正确的事件处理方法?


( A)mousePressed(MouseEvent e){}

B)MousePressed(MouseClick e){}

(C)functionKey(KeyPress k) {}

(D)ComponentAdded(keyPress e){}



(3)名为mon的监视器有5个线程在等候池;所有这些等待的线程具有相同的优先级。其中一个线程是thread1。如何通知thread1以便它单独从等待状态转移到就绪状态?

(A)执行通知(thread1);来自mon的同步代码。
(B)执行mon.notify(thread1);来自任何

对象的同步代码。


(C)执行thread1.notify();来自任何代码(同步或不同步)

任何对象。

(D)您无法指定将通知哪个线程。


(4)如何检索传递给小程序的圆的半径值?

(A)

public void init(){

String s = getParameter(" radius");

doSomethingWithRadius(s); }

(B)

public static void main(String [] args){

String s = getParameter(" radius");

DoSomethingWithRadius(s); }

(C)

public void init(){

int radius = getParameter(" radius");

doSomethingWithRadius(radius); }
(D)

public void init(){

int radius = getParameter();

doSomethingWithRadius(半径); }



true / false


1-方法drawRect(int a,int b,int c,int d)定义在

java.awt中绘制一个矩形的轮廓,其中a,b是左上角的x,y坐标,c,d是
右下角。
TRUE


2- Java中没有用于释放存储空间的声明。
FALSE // finalize()是使用


我再次真的希望你们可以帮我弄清楚我的答案是否正确。


在此先感谢

Hi again,

I''ve been solving these questions from past exam papers, and im not entirely confident about my answers. Im hoping that you guys can double check them for me.

These are the questions:

1- Which of the following methods must be over-ridden in order to tell the system how to execute a Thread?
(A) thread()
(B) execute()
(C) start()
(D) run()

2- Which of the following is a correct event handling method?

(A) mousePressed(MouseEvent e){}
(B) MousePressed(MouseClick e){}
(C) functionKey(KeyPress k){}
(D) ComponentAdded(keyPress e){}



(3) A monitor called mon has 5 threads in its waiting pool; all these waiting threads have the same priority. One of the threads is thread1. How can you notify thread1 so that it alone moves from Waiting state to Ready State?
(A) Execute notify(thread1); from within synchronized code of mon.
(B) Execute mon.notify(thread1); from synchronized code of any
object.

(C) Execute thread1.notify(); from any code(synchronized or not) of
any object.
(D) You cannot specify which thread will get notified.

(4) How can you retrieve a circle?s radius value that?s passed to an applet?
(A)
public void init() {
String s = getParameter("radius");
doSomethingWithRadius(s); }
(B)
public static void main(String[] args) {
String s = getParameter("radius");
DoSomethingWithRadius(s); }
(C)
public void init() {
int radius = getParameter("radius");
doSomethingWithRadius(radius); }
(D)
public void init() {
int radius = getParameter();
doSomethingWithRadius(radius); }


true/false

1- The method drawRect(int a, int b, int c, int d) defined in
java.awt draws the outline of a rectangle with a, b being the x,y coordinates of top left corner, and c,d being the x,y co-ordinates of the
bottom right corner.
TRUE

2- There is no statement in Java to free storage.
FALSE //finalize() is used

Once again im really hoping that you guys may help me figure out if my answers are correct or not.

Thanks in advance

推荐答案


再次


我''从过去的试卷中解决了这些问题,我对我的答案并不完全自信。我希望你们能为我仔细检查一下。


这些是问题:


1-为了告诉系统如何执行,必须覆盖以下哪些方法线程?

(A)线程()
(B)执行()

(C)start()

(D)run()


2-以下哪项是正确的事件处理方法?


( A)mousePressed(MouseEvent e){}

B)MousePressed(MouseClick e){}

(C)functionKey(KeyPress k) {}

(D)ComponentAdded(keyPress e){}



(3)名为mon的监视器有5个线程在等候池;所有这些等待的线程具有相同的优先级。其中一个线程是thread1。如何通知thread1以便它单独从等待状态转移到就绪状态?

(A)执行通知(thread1);来自mon的同步代码。
(B)执行mon.notify(thread1);来自任何
对象的同步代码。

(C)执行thread1.notify();来自任何代码(同步或不同步)

任何对象。

(D)您无法指定将通知哪个线程。


(4)如何检索传递给小程序的圆的半径值?

(A)

public void init(){

String s = getParameter(" radius");

doSomethingWithRadius(s); }

(B)

public static void main(String [] args){

String s = getParameter(" radius");

DoSomethingWithRadius(s); }

(C)

public void init(){

int radius = getParameter(" radius");

doSomethingWithRadius(radius); }
(D)
public void init(){
int radius = getParameter();
doSomethingWithRadius(半径); }


true / false


1-方法drawRect(int a,int b,int c,int d)定义在

java.awt中绘制一个矩形的轮廓,其中a,b是左上角的x,y坐标,c,d是
右下角。
TRUE


2- Java中没有用于释放存储空间的声明。
FALSE // finalize()是使用


我再次真的希望你们可以帮我弄清楚我的答案是否正确。


在此先感谢
Hi again,

I''ve been solving these questions from past exam papers, and im not entirely confident about my answers. Im hoping that you guys can double check them for me.

These are the questions:

1- Which of the following methods must be over-ridden in order to tell the system how to execute a Thread?
(A) thread()
(B) execute()
(C) start()
(D) run()

2- Which of the following is a correct event handling method?

(A) mousePressed(MouseEvent e){}
(B) MousePressed(MouseClick e){}
(C) functionKey(KeyPress k){}
(D) ComponentAdded(keyPress e){}



(3) A monitor called mon has 5 threads in its waiting pool; all these waiting threads have the same priority. One of the threads is thread1. How can you notify thread1 so that it alone moves from Waiting state to Ready State?
(A) Execute notify(thread1); from within synchronized code of mon.
(B) Execute mon.notify(thread1); from synchronized code of any
object.
(C) Execute thread1.notify(); from any code(synchronized or not) of
any object.
(D) You cannot specify which thread will get notified.

(4) How can you retrieve a circle?s radius value that?s passed to an applet?
(A)
public void init() {
String s = getParameter("radius");
doSomethingWithRadius(s); }
(B)
public static void main(String[] args) {
String s = getParameter("radius");
DoSomethingWithRadius(s); }
(C)
public void init() {
int radius = getParameter("radius");
doSomethingWithRadius(radius); }
(D)
public void init() {
int radius = getParameter();
doSomethingWithRadius(radius); }

true/false

1- The method drawRect(int a, int b, int c, int d) defined in
java.awt draws the outline of a rectangle with a, b being the x,y coordinates of top left corner, and c,d being the x,y co-ordinates of the
bottom right corner.
TRUE

2- There is no statement in Java to free storage.
FALSE //finalize() is used

Once again im really hoping that you guys may help me figure out if my answers are correct or not.

Thanks in advance



不幸的是,我的朋友你没有提出任何问题。你真的需要做更多的工作。


1)线程类中没有执行方法。你重写的方法是public void run():答案D


2)即使是mousePressed方法存在,拼写就像我用小写字母m拼写,所以Java就是区分大小写您的回答是错误的。 mousePressed也使用MouseEvent对象而不是MouseClick。事实上,没有MouseClick类,而是mouseClicked方法。正确答案是mousePressed(MouseEvent e){}:答案A

3)Object类中的方法notify()不带参数,唤醒正在等待的单个线程这个对象的监视器。如果有多个线程在等待此对象,则其中一个线程被任意选择,并且选择由实现决定。记住在Java中线程处理和垃圾收集是依赖于平台的:答案D

4)从applet中检索参数的事情是它们是字符串,即方法getParameter(String s)返回一个String对象,需要一个String来指定要检索的参数的名称。所以只有两个可能的解决方案是A和B.B是错误的,因为它试图在main方法中检索静态的参数并且不能引用非静态变量getParameter。答案A.


true / false

1)前两个参数是左上角的x,y坐标,但接下来的两个是矩形的长度和高度:答案错误

2)调用finalize不释放内存。在对象被垃圾收集时运行finalize方法,该过程将由底层操作系统启动,而不是由Java程序中的命令启动。您只能建议使用System.gc()收集系统垃圾,但这只是一个可以忽略的建议。:Answer true

Well unfortunately my friend you got none of the questions right. You really need to put in a bit more work.

1) There is no execute method in the thread class. The method you override is public void run():Answer D

2) Even the method mousePressed exists, it is spelled like I''ve done with small letter m and so Java being case sensitive your answer was wrong. Also mousePressed takes a MouseEvent object not a MouseClick. In fact there is no MouseClick class but a mouseClicked method. The correct answer was mousePressed(MouseEvent e){} :Answer A

3) The method notify() in the class Object takes no arguments and wakes up a single thread that is waiting on this object''s monitor. If there are more than one threads waiting on this object, one of them is chosen arbitrarily and the choice occurs at the discretion of the implementation. Remember in Java Thread handling and garbage collection are platform dependent: Answer D

4)The thing about retrieving parameters from applets is that they come as Strings i.e the method getParameter(String s) returns a String Object and requires a String specifying the name of the parameter to be retrieved. So the only 2 possible solutions are A and B. B is wrong because it attempts to retrieve the parameters in the main method which is static and cannot reference the non-static variable getParameter. Answer A.

true/false
1)The first two arguments are the x,y co-ordinates of the top left corner alright but the next two are the length and height of the rectangle:Answer false
2)Calling finalize does not free memory. The finalize method is run when an object is being garbage collected, a process which will have been started by the underlying OS not by a command from the Java program. You can only suggest that the system garbage collects using System.gc() but this is only a suggestion which can be ignored.:Answer true


这是不公平的! :(我整个星期都在学习java,我似乎无法得到任何正确的结果:(感谢您的帮助!!!希望我通过考试:(
This is unfair! :( I''ve been studying java all week and i cant seem to get anything right :( Thanks for your help!!! Hope i pass the exam :(



这是不公平的!:(我整个星期都在学习java,我似乎无法做任何事情:(感谢您的帮助!!!希望我通过考试:(
This is unfair! :( I''ve been studying java all week and i cant seem to get anything right :( Thanks for your help!!! Hope i pass the exam :(



你想写什么样的考试?

What kind of an exam do you want to write?


这篇关于帮助解决这些问题!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆