java英文SCGP试卷2
- 格式:doc
- 大小:45.00 KB
- 文档页数:11
全国计算机等级考试二级Java模拟试卷及答案Java语言程序设计一、选择题(1)Java语言具有许多优点和特点,下列选项中,哪个反映了Java程序并行机制的特点?A)安全性B)多线性C)跨平台D)可移植(2)下列哪个类声明是正确的?A)abstract final class HI{···}B)abstract private move(){···}C)protected private number; D)public abstract class Car{···}(3)下列关于for循环和while循环的说法中哪个是正确的?A)while循环能实现的操作,for循环也都能实现B)while循环判断条件一般是程序结果,for循环判断条件一般是非程序结果C)两种循环任何时候都可替换D)两种循环结构中都必须有循环体,循环体不能为空(4)异常包含下列那些内容?A)程序中的语法错误B)程序的编译错误C)程序执行过程中遇到的事先没有预料到的情况D)程序事先定义好的可能出现的意外情况(5)Character流与Byte流的区别是A)每次读入的字节数不同B)前者带有缓冲,后者没有C)前者是块读写,后者是字节读写D)二者没有区别,可以互换使用(6)监听事件和处理事件A)都由Listener完成B)都由相应事件Listener处登记过的构件完成C)由Listener和构件分别完成D)由Listener和窗口分别完成(7)Applet可以做下列那些操作?A)读取客户端文件B)在客户端主机上创建新文件C)在客户端装载程序库D)读取客户端部分系统变量(8)下列哪个属于容器的构件?A)JFrame B)JButton C)JPnel D)JApplet(9)如果希望所有的控件在界面上均匀排列,应使用下列那种布局管理器?A)BoxLayout B)GridLayout C)BorderLayout D)FlowLouLayout(10)为实现多线程之间的通信,需要使用下列那种流才合适?A)Filter stream B)File stream C)Random access stream D)Pipde stream二、填空题(1)对象串行化可以很容易地扩展成支持Java对象的[1],它提供了对象从流中重建的补充方式.(2)Vector类的对象是通过capacity和capacityIncrement两个值来改变集合的容量,其中capacity表示集合最多能容纳的[2] ,capacityIncrement表示每次增加多少容量,不是一个一个增加.(3)下列程序的功能是判断某一年是否为闰年.请在横线处填入适当内容,使程序能够正确运行.import java.io.*;public class LeapYear{public static void main(String arge[])throws IOException{InputStreamReader ir;BufferdeReadwe in;ir=new InputStreamReader(System.in);in=new BufferedReader(ir);System.out.println(“输入年份是:”);String s= [3]int year=Integer.parseInt(s);if year % 4 = = 0 && year % 100! = 0 // year % 400 = = 0){System.out.println(""+year+"年是闰年.");}else{System.out.println(""+year+"年不是闰年..");}}}(4)下面程序对数组中每个元素赋值,然后按逆序输出.请在横线处填入适当内容,使程序能正常运行.import java.io.*;public class ArrayTest{public static void main(String args[]){int i;int a[] = new int[5];for(i=0;i<5;i++)a=i;for( [4] i>=0;i- -)System.out.println("a["+i+"]="a);}}(5)下列程序的功能是:输入一个姓名,程序运行后,输出“姓名Welcome you!”.例如,输入“张三Welcomeyou !”.请在下面横线处填入正确的方法名,使程序可以正确运行.import java,awt,*;import java.awt.event.*;public class welcomenYou{public static void main(String args[]){new FrameInOut();}}class FrameInOut extends Frame implements ActionListener{Label prompt;TextField input,output;Button btnn;void FramInOut(){prompt=new Label("Please input your name");input=new TextField(10);output=new TextField(25);btnn=new Button("Class");[5] (new FlowLayout());add(prompt);add(input);add(output);add(btnn);input.addActionListener(this);btnn.addActionListener(this);setSize(300.200);show();}public void actionperformed(ActionEvent e){if(e.getSource() = = input)output.setText(input.getText()+"Welcome you!");else{dispose();system.exit(0);}}}Java程序设计答案一:选择题:1-5 :B D D C C6-10:B A A B D二:填空题:(1)[1]:持续存储或持久存储(2)[2]:元素个数(3)[3]:in.readLine()(4)[4]:i=a.Length-1(5)[5]:setLayout。
java二级考试试题及答案Java是一门广泛应用于软件开发领域的编程语言。
对于想要进一步提升自己的Java编程能力的人来说,参加Java二级考试是一个很好的机会。
本文将介绍一些常见的Java二级考试试题及其答案,希望对准备参加这个考试的人有所帮助。
1. 试题一:什么是Java中的多态性?请举一个示例说明。
答案:Java中的多态性是指同一个方法可以根据不同的对象调用不同的实现。
通过继承和接口的方式,一个父类或接口可以有多个不同的子类实现。
例如,有一个父类Animal,有两个子类Dog和Cat,它们都重写了父类的eat()方法。
当我们调用eat()方法时,可以根据具体的对象类型调用对应的实现,即可以调用Dog的eat()方法或Cat的eat()方法。
2. 试题二:Java中的异常处理机制是什么?请举一个示例说明。
答案:Java中的异常处理机制是通过try-catch-finally语句块来实现的。
当可能发生异常的代码块被包含在try块中时,如果发生异常,程序会跳转到对应的catch块进行异常处理。
finally块中的代码无论是否发生异常都会被执行。
例如,当我们读取一个文件时,可能会发生文件不存在的异常。
我们可以在try块中打开文件,如果发生异常,则在catch块中进行异常处理,最后在finally块中关闭文件。
3. 试题三:什么是Java中的线程?请举一个示例说明如何创建和启动一个线程。
答案:Java中的线程是指程序中独立执行的一段代码。
通过创建线程,我们可以同时执行多个任务,提高程序的效率。
可以通过继承Thread类或实现Runnable接口来创建线程。
例如,我们可以创建一个继承Thread类的MyThread类,重写run()方法,在run()方法中定义线程要执行的任务。
然后,我们可以通过创建MyThread对象并调用start()方法来启动线程。
4. 试题四:Java中的集合框架有哪些?请列举并简要说明各个集合类的特点。
java二级试题及答案一、选择题1.下列哪个选项用于创建一个类的实例?A. newB. thisC. finalD. void2.以下哪个关键字用于定义一个类的方法可以被子类重写?A. publicB. finalC. staticD. abstract3.以下哪个关键字用于定义一个类的成员变量可以被子类直接访问?A. privateB. protectedC. staticD. transient4.下列哪个选项是Java的基本数据类型?A. StringB. IntegerC. BooleanD. Double5.以下哪个选项是Java中的循环结构?A. forB. ifC. switchD. try二、填空题1. 声明一个整型变量并将其初始化为10:int num = _________ ;2. 定义一个常量并赋值为3.14:final double PI = _________ ;3. 定义一个字符串变量,并将其初始化为空串:String str =_________ ;4. 声明一个布尔变量并将其初始化为真:boolean flag = _________ ;5. 将两个整数相加并将结果赋值给一个整型变量:int sum =_________ + _________ ;三、编程题1. 编写一个Java程序,实现输入一个整数n,并输出1到n之间所有偶数的和。
示例输入:10示例输出:302. 编写一个Java程序,实现输入一个字符串,判断该字符串是否是回文串(正序和反序读都一样)。
示例输入:radar示例输出:是回文串3. 编写一个Java程序,实现输入一个整数n,并输出斐波那契数列的前n项。
示例输入:5示例输出:0 1 1 2 3四、简答题1. 什么是Java的面向对象特性?举例说明面向对象编程的好处。
2. Java中的继承和多态的概念分别是什么?它们如何实现面向对象的特性?3. Java中的异常处理机制是什么?说明try-catch-finally语句的作用和使用方法。
SUN认证Java2程序员考试(SCJP) 试题解析(2)SUN认证Java2程序员考试(SCJP) 试题解析(2) which of the following lines of code will pile without error?a.int i=0;if (i) {system.out.println(“hi”);}b.boolean b=true;boolean b2=true;if(b==b2) {system.out.println(“so true”); }c.int i=1;int j=2;if(i==1|| j==2)system.out.println(“ok”);d.int i=1;int j=2;if (i==1 &| j==2)system.out.println(“ok”);解答:b, c点评:选项a错,因为if语句后需要一个boolean类型的表达式。
逻辑操作有^、&、| 和 &&、||,但是“&|”是非法的,所以选项d不正确。
例题5:which two demonstrate a "has a" relationship? (choose two) a. public interface person { }public class employee extends person{ }b. public interface shape { }public interface rectandle extends shape { }c. public interface colorable { }public class shape implements colorable{ }d. public class species{ }public class animal{private species species;}e. interface ponent{ }class container implements ponent{private ponent[] children;}解答:d, e点评:在java中代码重用有两种可能的方式,即组合(“has a”关系)和继承(“is a”关系)。
全国计算机等级考试二级Java模拟试卷及答案Java一、选择题(1)Java语言具有许多优点和特点,下列选项中,哪个反映了Java程序并行机制的特点?BA)安全性 B)多线性 C)跨平台 D)可移植(2)下列哪个类声明是正确的?DA)abstract final class HI{} B)abstract private move(){}C)protected private number; D)public abstract class Car{}(3)下列关于for循环和while循环的说法中哪个是正确的?DA)while循环能实现的操作,for循环也都能实现B)while循环判断条件一般是程序结果,for循环判断条件一般是非程序结果C)两种循环任何时候都可替换D)两种循环结构中都必须有循环体,循环体不能为空(4)异常包含下列那些内容?CA)程序中的语法错误B)程序的编译错误C)程序执行过程中遇到的事先没有预料到的情况D)程序事先定义好的可能出现的意外情况(5)Character流与Byte流的区别是CA)每次读入的字节数不同 B)前者带有缓冲,后者没有C)前者是块读写,后者是字节读写 D)二者没有区别,可以互换使用(6)在设计程序时,应采纳的原则之一是 DA.不限制goto语句的使用 B.减少或取消注解行C.程序越短越好 D.程序结构应有助于读者理解(7)程序设计语言的基本成分是数据成分、运算成分、控制成分和 DA.对象成分 B.变量成分1C.语句成分 D.传输成分(8)下列叙述中,不属于软件需求规格说明书的作用的是 DA.便于用户、开发人员进行理解和交流B.反映出用户问题的结构,可以作为软件开发工作的基础和依据C.作为确认测试和验收的依据D.便于开发人员进行需求分析(9)下列哪个选项是合法的标识符?BA.123 B._name C.class D.1first (10)下列哪个选项是Java调试器,如果编译器返回程序代码的错误,可以用它对程序进行调试? CA.java.exe B.javadoc.exe C.jdb.exe D.javaprof.exe (11)下列关于继承的哪项叙述是正确的? DA.在java中允许多重继承B.在java中一个类只能实现一个接口C.在java中一个类不能同时继承一个类和实现一个接口 D.java的单一继承使代码更可靠(12)下列哪个修饰符可以使在一个类中定义的成员变量只能被同一包中的类访问? BA.private B.无修饰符 C.public D.protected (13)给出下列代码,如何使成员变量m 被方法fun()直接访问? C class Test{private int m;public static void fun(){...}2}A.将private int m 改为protected int m B.将private int m 改为public int m C.将private int m 改为 static int m D.将private int m 改为 int m (14)已知有下列类的说明,则下列哪个语句是正确的?A public class Test{private float f = 1.0f;int m = 12;static int n=1;public static void main(String arg[]){Test t = new Test();}}A.t.f; B.this.n; C.Test.m; D.Test.f;(15)下列代码的执行结果是 A public class Test{public int aMethod(){static int i=0;i++;System.out.println(i);3}public static void main(String args[]){Test test = new Test();test.aMethod();}}A.编译错误 B.0 C.1 D.运行成功,但不输出(16)下列关于内部类的说法不正确的是CA.内部类的类名只能在定义它的类或程序段中或在表达式内部匿名使用 B.内部类可以使用它所在类的静态成员变量和实例成员变量 C.内部类不可以用abstract修饰符定义为抽象类D.内部类可作为其他类的成员,而且可访问它所在类的成员(17)顺序执行下列程序语句后,则b的值是 CString a="Hello";String b=a.substring(0,2);A.Hello B.hello C.Hel D.null (18)在oneMethod()方法运行正常的情况下,程序段将输出什么? D public void test(){try { oneMethod();System.out.println("condition 1");} catch (ArrayIndexOutOfBoundsException e){System.out.println("condition 2");} catch(Exception e)4{System.out.println("condition 3");} finally{System.out.println("finally");}}A.condition 1 B.condition 2 C.condition 3 D.condition 1finally (19)下列常见的系统定义的异常中,哪个是输入、输出异常? B A.ClassNotFoundException B.IOException C.FileNotFoundException D.UnknownHostException (20)下列哪个选项是正确计算42度(角度)的余弦值?C A.double d=Math.cos(42);B.double d=Math.cosine(42);C.double d=Math.cos(Math.toRadians(42));D.double d=Math.cos(Math.toDegrees(42));(21)下列InputStream类中哪个方法可以用于关闭流?B A.skip() B.close() C.mark() D.reset()(22)下列方法中哪个是执行线程的方法?AA.run() B.start() C.sleep() D.suspend()(23)下列关于Frame类的说法不正确的是 CA.Frame是Window类的直接子类B.Frame对象显示的效果是一个窗口C.Frame被默认初始化为可见D.Frame的默认布局管理器为BorderLayout5(24)下列Java常见事件类中哪个是鼠标事件类? C A.InputEventB.KeyEventC.MouseEventD.WindowEvent(25)在Applet的关键方法中,下列哪个方法是关闭浏览器以释放Applet占用的所有资源? DA.init()B.start()C.paint()D.destroy()(26)下列哪个是面向大型企业级用容器管理专用构件的应用平台? AA.J2EEB.J2MEC.J2SED.J2DE(27)下列哪个选项的java源文件代码片段是不正确的? BA.package testpackage;public class Test{ }B.import java.io.*;package testpackage;public class Test{ }C.import java.io.*;class Person{ }public class Test{ }D.import java.io.*;6import java.awt.*;public class Test{ }二、填空题(1)对象串行化可以很容易地扩展成支持Java对象的 [1],它提供了对象从流中重建的补充方式。
JAVA认证历年真题:SCJP考试真题和解析[2]1. Which of the following range of short is correct?A. -27 -- 27-1B. 0 -- 216-1C. ?215 -- 215-1D. ?231 -- 231-1翻译下面哪些是short型的取值范围。
答案答案C解析解析短整型的数据类型的长度是16 bits,有符号。
另外需要说明的是java中所有的整(Integral)数(包括byte,short,int,long)全是有符号的。
2. Which declarations of identifiers are legal?A. $personsB. TwoUsersC. *pointD. thisE. _endline翻译下面哪些是合法的标识符。
翻译下面哪些是合法的标识符。
答案答案A,B,E解析解析Java的标识符可以以一个Unicode字符,下滑线(_),美元符($)开始,后续字符可以是前面的符号和数字,没有长度限制,大小写敏感,不能是保留字。
3. Which statement of assigning a long type variable to a hexadecimal value is correct?A. long number = 345L;B. long number = 0345;C. long number = 0345L;D. long number = 0x345L翻译哪些是将一个十六进制值赋值给一个long型变量。
答案答案D解析十六进制数以0x开头,long型数以L(大小写均可,一般使用大写,因为小写的l和数字1不易解析区分)。
4.Which of the following fragments might cause errors?A. String s = "Gone with the wind";String t = " good ";String k = s + t;B. String s = "Gone with the wind";String t;t = s[3] + "one";C. String s = "Gone with the wind";String standard = s.toUpperCase();D. String s = "home directory";String t = s - "directory";翻译下面的哪些程序片断可能导致错误。
java二级试题及答案一、选择题(每题2分,共10题,共计20分)1. 下面哪个选项不是Java关键字?A. classB. packageC. finalD. import2. 下面哪种循环语句可以用于遍历数组或集合?A. forB. whileC. do-whileD. switch3. Java中的包(package)用于什么目的?A. 控制类的访问权限B. 封装类的属性和方法C. 组织类的层次结构D. 使类具有继承特性4. 在Java中,以下哪个关键字用于定义一个类的子类?A. superB. thisC. extendsD. implements5. 下面哪个选项不是Java中的访问修饰符?A. privateB. protectedC. publicD. static6. 在Java中,以下哪个方法用于启动一个新的线程?A. start()B. run()C. execute()D. launch()7. 在Java中,以下哪个异常类是所有异常的父类?A. ExceptionB. RuntimeExceptioinC. ErrorD. Throwable8. 在Java中,以下哪个关键字用于定义常量?A. varB. constC. finalD. static9. 在Java中,以下哪种集合类用于存储键值对?A. ArrayListB. HashSetC. LinkedListD. HashMap10. 下面哪个选项不是Java中的基本数据类型?A. intB. doubleC. booleanD. string二、填空题(每空2分,共5题,共计10分)1. Java中的数据类型分为两类,分别为基本数据类型和_____________。
2. Java中的三目运算符的格式是_____________。
3. 在Java中,方法的重载是指在同一个类中,方法名相同但参数类型或个数_____________的情况下可以存在多个方法。
QUESTION 61GIVEN THE EXHIBIT:Which statement is true?A. All of the assert statements are used appropriately.B. Only the assert statement on line 31 is used appropriatelyC. The assert statements on lines 29 and 31 are used appropriatelyD. The assert statements on lines 26 and 29 are used appropriatelyE. The assert statements on lines 29 and 33 are used appropriatelyF. The assert statements on lines 29 ,31and 33 are used appropriatelyG. The assert statements on lines 26,29 and 31 are used appropriately断言应该用在“你认为”你的程序不可能产生错误的地方,而且有没有启用断言,都不会影响程序的正常运行。
断言使用限制:1.不要在public方法中,用断言来检查参数的正确性;2.不要让断言语句去处理一些程序必须的流程。
原因:1.public方法会被别人调用,你不能保证他一定启用断言;如果没有启用,那么用断言来做参数的检查也就没有意义了。
所以不要用断言来检查参数,公共方法的参数一定要用代码执行检查; 2.如果用断言来控制程序执行流程,如果没有启用断言,那么程序就不能正确执行下去。
另外,断言语句不可以有任何边界效应,不要使用断言语句去修改变量和改变方法的返回值,如果这样当启动断言和不启动断言执行的结果会截然不同。
断言的使用时机:1.检查流程的不变性:在if-else switch-case 的预期结果之外可以加上断言做额外的检查。
SUN认证Java2程序员考试(SCJP) 试题解析(2)SUN认证Java2程序员考试(SCJP) 试题解析(2)SUN认证Java2程序员考试(SCJP) 试题解析(2)whichofthefollowinglinesofcodewillcompilewithouterror?a.inti=0;if(i){system.out.println( hi );}b.booleanb=true;booleanb2=true;if(b==b2){system.out.println(whichtwodemonstratea"hasa"relationship?(choosetwo)a.publicinterfaceperson{}publicclassemployeeextendsperson{}b.publicinterfaceshape{}publicinterfacerectandleextendsshape{}c.publicinterfacecolorable{}publicclassshapeimplementscolorable{}d.publicclassspecies{}publicclassanimal{privatespeciesspecies;}e.interfacecomponent{}classcontainerimplementscomponent{privatecomponent[]children;}解答:d,e点评:在java中代码重用有两种可能的方式,即组合(hasa 关系)和继承(isa 关系)。
hasa 关系是通过定义类的属性的方式实现的;而isa 关系是通过类继承实现的。
本例中选项a、b、c体现了isa 关系;选项d、e体现了hasa 关系。
例题6:whichtwostatementsaretruefortheclassjava.util.treeset?(ch oosetwo)a.theelementsinthecollectionareordered.b.thecollectionisguaranteedtobeimmutable.c.theelementsinthecollectionareguaranteedtobeunique.d.theelementsinthecollectionareaccessedusingauniquekey.e.theelementsinthecollectionareguaranteedtobesynchroni zed解答:a,c点评:treeset类实现了set接口。
question 1)what will happen when you attempt to compile and run this code?abstract class base{abstract public void myfunc();public void another(){system.out.println("another method");}}public class abs extends base{public static void main(string argv[]){abs a = new abs();a.amethod();}public void myfunc(){system.out.println("my func");}public void amethod(){myfunc();}}1) the code will compile and run, printing out the words "my func"2) the compiler will complain that the base class has non abstract methods3) the code will compile but complain at run time that the base class has non abstract methods4) the compiler will complain that the method myfunc in the base class has no body, nobody at all to looove itquestion 2)what will happen when you attempt to compile and run this code?public class mymain{public static void main(String argv){System.out.println("hello cruel world");}}1) the compiler will complain that main is a reserved word and cannot be used for a class2) the code will compile and when run will print out "hello cruel world"3) the code will compile but will complain at run time that no constructor is defined4) the code will compile but will complain at run time that main is not correctly definedquestion 6)what will happen when you attempt to compile and run this code?class base{public final void amethod(){System.out.println("amethod");}}public class fin extends base{public static void main(String argv[]){base b = new base();b.amethod();}}1) compile time error indicating that a class with any final methods must be decl ared final itself2) compile time error indicating that you cannot inherit(继承) from a class with final methods3) run time error indicating that base is not defined as final4) success in compilation and output of "amethod" at run timequestion 8)what will happen when you attempt to compile and run this code?private class base{}public class vis{transient int ival;public static void main(String elephant[]){}}1)compile time error: base cannot be private2)compile time error indicating that an integer cannot be transient3)compile time error transient not a data type4)compile time error malformed main methodquestion 9)what happens when you attempt to compile and run these two files in the same directory?//file p1.javapackage mypackage;class p1{void afancymethod(){system.out.println("what a fancy method");}}//file p2.javapublic class p2 extends p1{public static void main(String argv[]){p2 p2 = new p2();p2.afancymethod();}}1) both compile and p2 outputs "what a fancy method" when run2) neither will compile3) both compile but p2 has an error at run time4) p1 compiles cleanly but p2 has an error at compile timequestion 10)you want to find out the value of the last element of an array. you write the following code. what will happen when you compile and run it.?public class myar{public static void main(String argv[]){int[] i = new int[5];System.out.println(i[5]);}}1) an error at compile time2) an error at run time3) the value 0 will be output4) the string "null" will be outputquestion 18)what will happen when you attempt to compile and run the following code?public class bground extends thread{public static void main(string argv[]){bground b = new bground();b.run();}public void start(){for (int i = 0; i <10; i++){system.out.println("value of i = " + i);}}}1) a compile time error indicating that no run method is defined for the thread class2) a run time error indicating that no run method is defined for the thread class3) clean compile and at run time the values 0 to 9 are printed out4) clean compile but no output at runtimequestion 25)what will happen when you attempt to compile and run the following codepublic class hope{public static void main(String argv[]){hope h = new hope();}protected hope(){for(int i =0; i <10; i ++){System.out.println(i);}}}1) compilation error: constructors cannot be declared protected2) run time error: constructors cannot be declared protected3) compilation and running with output 0 to 104) compilation and running with output 0 to 9question 26)what will happen when you attempt to compile and run the following codepublic class myswitch{public static void main(String argv[]){myswitch ms= new myswitch();ms.amethod();}public void amethod(){int k=10;switch(k){case 10:system.out.println("ten");case 20:system.out.println("twenty");break;default:system.out.println("this is the default output");break;}}}1) none of these options2) compile time error target of switch must be an integral type3) compile and run with output "this is the default output"4) compile and run with output of the single line "ten"question 28)what will happen when you attempt to compile and run the following codepublic class as{int i = 10;int j;char z= 1;boolean b;public static void main(String argv[]){as a = new as();a.amethod();}public void amethod(){System.out.println(j);System.out.println(b);}}1) compilation succeeds and at run time an output of 0 and false2) compilation succeeds and at run time an output of 0 and true3) compile time error b is not initialised4) compile time error z must be assigned a char valuequestion 29)what will happen when you attempt to compile and run the following code with the command line "hello there"public class arg{string[] myarg;public static void main(string argv[]){myarg=argv;}public void amethod(){System.out.println(argv[1]);}}1) compile time error2) compilation and output of "hello"3) compilation and output of "there"4) none of the abovequestion 30)what will happen when you attempt to compile and run the following codepublic class streq{public static void main(string argv[]){streq s = new streq();}private streq(){string s = "marcus";string s2 = new string("marcus");if(s = = s2){system.out.println("we have a match");}else{system.out.println("not equal");}}}1) compile time error caused by private constructor2) output of "we have a match"3) output of "not equal"4) compile time error by attempting to compare strings using == question 31)what will happen when you attempt to compile and run the following codeimport java.io.*;class base{public void amethod()throws filenotfoundexception{}}public class excepdemo extends base{public static void main(string argv[]){excepdemo e = new excepdemo();}public void amethod(){}protected excepdemo(){try{datainputstream din = new datainputstream(system.in);system.out.println("pausing");din.readbyte();system.out.println("continuing");this.amethod();}catch(ioexception ioe) {}}}1) compile time error caused by protected constructor2) compile time error caused by amethod not declaring exception3) runtime error caused by amethod not declaring exception4) compile and run with output of "pausing" and "continuing" after a key is hitquestion 32)what will happen when you attempt to compile and run this programpublic class outer{public string name = "outer";public static void main(string argv[]){inner i = new inner();i.showname();}//end of mainprivate class inner{string name =new string("inner");void showname(){system.out.println(name);}}//end of inner class}1) compile and run with output of "outer"2) compile and run with output of "inner"3) compile time error because inner is declared as private4) compile time error because of the line creating the instance of innerquestion 34)which option most fully describes will happen when you attempt to compile and run the following codepublic class myar{public static void main(string argv[]) {myar m = new myar();m.amethod();}public void amethod(){static int i;system.out.println(i);}}1) compilation and output of the value 02) compile time error because i has not been initialized3) compilation and output of null4) compile time errorquestion 35)which of the following will compile correctly1)short myshort = 99s;2) string name = 'excellent tutorial mr green';3) char c = 17c;4)int z = 015;question 38)given the following main method in a class called cycle and a command line of java cycle one twowhat will be output?public static void main(string bicycle[]){system.out.println(bicycle[0]);}1) none of these options2) cycle3) one4) twoquestion 41)given the following codeclass base{}public class mycast extends base{static boolean b1=false;static int i = -1;static double d = 10.1;public static void main(string argv[]){mycast m = new mycast();base b = new base();//here}}which of the following, if inserted at the comment //here will allow the code to compile and run without error1) b=m;2) m=b;3) d =i;4) b1 =i;question 45)what will happen when you attempt to compile and run the following codeint output=10;boolean b1 = false;if((b1= =true) && ((output+=10)==20)){system.out.println("we are equal "+output);}else{system.out.println("not equal! "+output);}1) compile error, attempting to peform binary comparison on logical data type2) compilation and output of "we are equal 10"3) compilation and output of "not equal! 20"4) compilation and output of "not equal! 10"question 48)given the following variableschar c = 'c';int i = 10;double d = 10;long l = 1;string s = "hello";which of the following will compile without error?1)c=c+i;2)s+=i;3)i+=s;4)c+=s;question 51)given the following code what will be the output?class valhold{public int i = 10;}public class obparm{public static void main(string argv[]){obparm o = new obparm();o.amethod();}public void amethod(){int i = 99;valhold v = new valhold();v.i=30;another(v,i);system.out.print( v.i );}//end of amethodpublic void another(valhold v, int i){i=0;v.i = 20;valhold vh = new valhold();v = vh;system.out.print(v.i);system.out.print(i);}//end of another}1) 100302) 200303) 2099304) 10020question 53)given the following class definition which of the following can be legally placed after the comment line//here ?class base{public base(int i){}}public class myover extends base{public static void main(string arg[]){myover m = new myover(10); }myover(int i){super(i);}myover(string s, int i){this(i);//here}}1)myover m = new myover();2)super();3)this("hello",10);4)base b = new base(10);。