This article is a mirror article of machine translation, please click here to jump to the original article.

View: 26843|Reply: 7

[Source] Javaoop50 Inside Questions

[Copy link]
Posted on 11/16/2014 4:32:47 PM | | |
1. .Given twojavaProcedure,As follows:Text.javaThe result of the compilation run is (choose one)
pubilc interface Face{
   int count = 40;
}
pubilc class Text implements Face{
    private static int counter;
    pubilc static void main(String[]args){
        System.out.println( counter );
    }
}
A40
B41
C0
D1
2. JavaA value entered by the user is read in the program, and a custom exception is required to be created if the input value is greater than10, usethrowThe statement explicitly raises an exception, and the exception output message is "somethings wrong! ", the sentence is (choose one)
Aif (I>10)  throw Exception("somethings wrong");
Bif (I>10)  throw Exception e ("somethings wrong");
Cif (I>10)  throw new Exception("somethings wrong");
Dif (I>10) throw new Exception e ("somethings wrong");
3. JavaClasses in programs are defined as follows:
class Demo {
    private int[] count;
    public Demo(){
        count=new int[10];
    }
    public void setCount(int ct,int n){
        count[n]=ct;
    }   
    public int getCount(int n){
        return count[n];
    }
    public void showCount(int n){
        System.out.println("Count is "+count[n]);
    }
}
in creationDemoinstance of the class, by callingshowCount(9)The result of the method is (choose one)
ACount is 0
BCount is null
C, compilation errors
D, runtime errors
4. javaThe program contains the following code:
DataInputStream din = new DataInputStream
    new BufferedInputStream(new FileInputStream("employee.dat") ));
Assuming inemployee.datThe file contains only the following characters:abcdefg。 Then:System.out.println(din.read())Print on the screen (choose one)
AA
BB
C97
D98
5. javaIn the language, the following are based on all classes that handle output operations (choose one)
ADataOutput
BOutputStream
CBufferedOutputStream
DIOStream
6. Java, when using the () modifier, a class can be accessed by other classes in the same package or different packages. (Choose one)
Aprivate
Bprotected
Cpublic
Dfriendly
7. public class Test {
    public static void main(String args[]){
        EqTest e = new EqTest();
        e.show();
    }
}
class  EqTest{
    String s = "Java";
    String s2 = "java";
    public void show(){
        //Place the test code here
        {System.out.println("Equal"); }
        else
        {System.out.println("Not equal"); }
    }
}
On the topJavaThe comment line position of the code, placing () the test code will output an "equal" result. (Choose one)
Aif(s==s2)
Bif(s.equals(s2))
Cif(s.equalsIgnoreCase(s2))
Dif(s.noCaseMatch(s2))
8. Packagepack1Classclass1There are member methods:
protected void method_1(){}
private void method_2(){…},
public void method_3(){}andvoid method_4(){},In the packagepack2classclass2beclass1The subclass is in youclass2(choose two)
Amethod_1
Bmethod_2
Cmethod_3
Dmethod_4
9. Compile and run the followingJavaProcedure:
class A{
    int var1=1;
    int var2;
    public static void main(String[] args){
        int var3=3;
        A a = new A();
        System.out.println(a.var1+a.var2+var3);
    }
}
will be generated(  )Result. (Choose one)
A0
B4
C3
D, the code cannot be compiled becausevar2Not initialized at all
10. Compile and run the followingJavaCode snippet
char c = 'a';
switch (c) {
     case 'a': System.out.println("a");
     default: System.out.println("default");
  }
The output result is (choose one)
A, the code cannot be compiled becauseswitchThere is no legal expression for a statement
Ba  default
Ca
Ddefault
11. Analyze the followingJavaCode:
class A{
    public static void main(String[] args){
        method();
    }
    static void method(){
        try{
            System.out.println("Hello");
        }
        finally{
           System.out.println("good-bye");
        }
    }
}
After the compilation runs, the output is (choose one)
A、“Hello
B、“good-bye
C、“Hello good-bye
D, the code cannot be compiled
12. Analyze the followingJavaProcedure:
public class ExceptionTest {
public static void main(String[]  args) throws Exception {
    try {
        throw new Exception();
    }
    catch(Exception e){
        System.out.println("Caught in main()");
    }   
    System.out.println("nothing");
}
}
The output result is (choose one)
ACaught in main()nothing
BCaught in main()
Cnothing
D, without any output
13. GivesJavaThe code is as follows, To print outlistcontent stored in the,The following statement is correct (choose two)
ArrayList list= new ArrayList();
list.add("a");
list.add("b");
ASystem.out.print(list);
BSystem.out.print(list.toArray());
CSystem.out.print(list.toString());
DSystem.out.print(list.get(0));
14. GivesJavaCode, as follows:
abstract class Shape{
    abstract void draw();
}
To createShapesubclasses of classesCircle, the following code is correct (choose two)
Aclass Circle extends Shape{int draw(){}}
Babstract class Circle extends Shape{  }
Cclass Circle extends Shape{void draw(); }
Dclass Circle extends Shape{void draw(){}; }
15. GivesjavaThe code is as follows: compile run, and the result is (choose one)
public static void main(String[] args) {
    String s ;
    System.out.println( "s=" + s);
}
A, compilation errors
B, compile passes, but there is a runtime error
C, normal operation, outputs=null
D, normal operation, outputs=
16. GivenjavaThe code, as follows: When running, an exception of type () is generated. (Choose one)
String s = null;
s.concat("abc");
AAritthmeticException
BNullpointerException
CIOException
DEOFException
17. GivesjavaThe code snippet is as follows:
Integer a = new Integer(3);
Integer b = new Integer(3);
System.out.println(a==b);
After running, this code will be output (choose one)
A1
B0
Ctrue
Dfalse
18. GivesjavaThe code is as follows,dThe value range is (choose one)
double d = Math.random();
Ad>=1.0
Bd>=0.0,moreoverd<1.0
Cd>=0.0,moreoverd<Double.MAX_VALUE
Dd>=1.0,moreoverd<Double.MAX_VALUE
19. GivenJavaThe code is as follows, and when runtime, it will be generated(  )type of anomaly. (Choose one)
String s = null;
s.concat("abc");
AArithmeticException
BNullPointerException
CIOException
DEOFException
20. Given so-and-soJavaproceduralmainThe method is as follows, the result of the program compilation and run is (choose one)
public static void main(String[]args){
    String str = null;
    str.concat("abc");
    str.concat("def");
    System.out.println(str);
}
Anull
Babcdef
C, compilation errors
D, abnormalities occur during runtime
21. Given as followsJAVAProgram fragments:
class A{
    public A(){
        system.out.println("A");
    }
}
class B extends A{
    public B(){ System.out.println("B"); }
    public static void main(String[] args){
        B b = new B();
    }
}
The above procedures will (choose one)
A, cannot be compiled
B, through compilation,The output is: A B
C, through compilation,The output is: B
D, through compilation,The output is: A
22. Given as followsJavacode, will be in the compilation time(  )An error occurred. (Choose one)
class Parent{  }
class Child extends Parent{
    public static void main(String args[]){
        Parent p1 = new Child();        //First line
        Parent p2 = new Parent();        //Second line
        Child c1 = new Child();                //Third row
        Child c2 = new Parent();        //Fourth line
    }
}
A, the first line
B, the second line
C, the third line
D, the fourth line
23. Given as followsJavaCode, compile runtime, below(  )The value of the statement istrue。 (Choose two)
String s = "hello";
String t = "hello";
String e = new String("hello");
char[] c = {'h','e','l','l','o'};
As.equals( t )
Bt.equals( c )
Ct.equals( e )
Dt==c
24. Given oneJavaThe program code is as follows: After running the compilation, the output result is (choose one)
pubilc class Test{
    int count = 9;
    pubilc void count1(){
        int count = 10;
        System.out.println("count1" + count);
    }
    pubilc void count2(){
        System.out.println("count2" + count);
    }
    pubilc static void main(String args[]){
        Test t = new Twst();
        t.count1();
        t.count2();
    }
}
Acount1=9 count2=9
Bcount1=10 count2=9
Ccount1=10 count2=10
Dcount1=9 count2=10
25. Given oneJavaThe code fragment of the program is as follows, after running, the correct output result is (choose one)
String s="hello,world";
s.replace(","," ");
System.out.println(s);
Ahello world;
Bhello, world
CHELLO WORLD;
DHELLO ,WORLD;
26. Give onejavaThe methodological structure of the procedure is as follows:
public Integer change(String s){
}
The following methodology implementation statements are correct (choose two)
Areturn new Integer(s);
Breturn s;
CInteger t = Integer.valueOf(s); return t;
Dreturn s.getInteger();
27. The interface is defined as follows:
interface A {
    int method1(int i);
    int method2(int j);
}
kindBImplements interfacesA, below(  )That's right. (Choose one)
Aclass B implements A {int method1() { }int method2() { }}
Bclass B {int method1(int i) { }int method2(int j) { }}
Cclass B implements A {int method1(int i) { }int method2(int j) { }}
Dclass B extends A {int method1(int i) { }int method2(int j) { }}
28. As followsJavaCode snippet, embodying the concept of (). (Choose one)
public void aMethod(String s){....}
public void aMethod(int i){.........}
public void aMethod(int i,float f){.....}
A, more inheritance
B, heavy load
C, rewrite
D, polymorphism
29. To judge two stringss1ands2Whether they are equal or not, they should be used (choose one)
Aif (s1==s2)
Bif (s1=s2)
Cif (strcpy(s1s2))
Dif (s1.equals(s2))
30. The following descriptions in the class are incorrect (choose one)
AA class is a group of objects with the same characteristics, common behaviors and common relationships
B, class is the specific manifestation of the object in the real world
C, similar objects are grouped into a class, each describing a set of independent objects
D, object is an instance of a class, and class structure is a practical form of object abstraction
31. The output of the following program is (choose one)
class A2 extends A1 {
    A2(){
        System.out.println("A2");
    }
    public static void main(String args[]){
        new A2();
    }
}
class  A1{
    A1(){
        System.out.println("A1");
    }
}
AA1
BA2
CA1A2
DA2A1
32. The following are:JavaSome declarations in the program, one of the options that can be compiled is (choose one)
String s1 = new String("Hello");
String s2 = new String("there");
String s3 = new String();
As3 = s1 + s2
Bs3 = s1s2
Cs3 = s1 || s2
Ds3 = s1 - s2
33. Research the followingJavaCode:
public class testException{
    public static void main(String args[]){
        int n[]={0,1,2,3,4};
        int sum=0;
        try {
            for(int i=1; i<6; i++)
                sum=sum+ n;
            System.out.println("sum="+sum);
        }
        catch(ArrayIndexOutOfBoundsExpception e) {
            System.out.println("The array crosses the boundary");
        }
        finally{
            System.out.println("End of the procedure");
        }
    }
}
The output will be (select one)
A10  Array Outbounds program ends
B10  End of the procedure
C, the array is out of bounds, and the procedure ends
D, the end of the procedure
34. To useJavaCreate a new directory with an instance of class () below. (Choose one)
AFile
BFileoutputStream
CPrintwriter
DBufferedReader
35. BelowJavain the statement,(  )Can construct oneDataOutputStreamObject. (Choose one)
Anew DataOutputStream(new FileOutputStream("abc.txt"));
Bnew DataOutputStream(new OutputStream("abc.txt"));
Cnew DataOutputStream(new FileWriter("abc.txt"));
Dnew DataOutputStream(new FileInputStream("abc.txt"));
36. InJ2EE, the compilation error in the following code is (choose one)
AFile f = new File("/","autoexec.bat");
BDataInputStream din = new DataInputStream(new FileInputStream("autoexec.bat"));
CInputStreamReader in = new InputStreamReader(System.in);
DOutputStreamWriter out = new OutputStreamWriter(System.in);
37. InJ2SE, the sorted collection class of the following elements is (choose one)
ALinkedList
BStack
CHashtable
DTreeSet
38. InJava.langPackagedMathIn the class, the method of finding the maximum value is (select one)
AMax()
BMin()
CAbs()
DCeil()
39. Injavacan be separately withfinallyThe blocks used together with the statement are (choose one)
Atry
Bcatch
Cthrow
Dthrows
40. InJavaIn a language, when a variable of a class is declared as protectedThe following statements are correct (choose two)
A, only members of the same class can access it
B, any other class in a different package will be able to access it
C, any other class in the same package can access it
D, subclasses in different packages can access the variable
41. InJavaIf you have the following class definition:
abstract class Shape{
    abstract void draw();
}
Class Square extends Shape{}
If you try to compile the above code will happen (choose one)
A, everything is successfully compiled
BShapecan be compiled,SquareCannot compile
CSquarecan be compiled,ShapeCannot compile
DShapeSquareNone of them can be compiled
42. InJavaIn the language, Xiao Ming was in his bagmypackageclassMy_Class, inmypackageSubpackagemysubpackageThere is also a category in the middleMy_Class。 Xiao Ming used.import mypackage: Introduce the package and execute the statement in it:My_Class NewClass=New My_Class();will occur (select one)
A, create a classmypackage. My_ClassObject
B, create a classmypackage. Mysubpackage.My_Classobject
C, the statement is wrong
D, create a classmypackage. My_Classobject and a classmypackage. Mysubpackage.My_Classobject
43. InJavaIn language, Xiao Ming is in his classSquareRootThe method is defined in themethod_Awith a statement:
double my_result=Math.sqrt(1000); He needs to import (choose one)
AJava.awt.*
BJava.Math.*
CJava.util.Math.*
DNone of the above is true
44. InJavaMedium,()The interface is located at the top level of the collection framework. (Choose one)
AMap
BCollection
CSet
DList
45. InJAVAmedium,comMethods of a certain class in the package can be modified by using the following () access modifierscom.dbsubclass in the package, but cannot be accessed bycom.dbOther class access. (Choose one)
Aprivate
Bprotected
Cpublic
Dfriendly
46. InJavaIn the middle, callMath.random()The result that the method might return is (). (Choose one)
A132.34
B0.342
C29.34E10
D1.0009
47. InJavaIn the middle, callMath.random()The result that the method may return is (choose one)
A132.34
B0.342
C29.34E10
D1.0009
48. Injava, the keywords that define the interface are (choose one)
Aclass
Binterface
Cextends
Dimplements
49. InJavaAccording to your understanding, the following methods(  )It can't be a classOrangeconstruction method. (Choose one)
AOrange(){}
BOrange(){… }
Cpublic void Orange(){}
Dpublic Orange(){}
50. InJava, Guan Jian () makes the class unable to derive subclasses. (Choose one)
Afinal
Bpublic
Cprivate
Dvolatile
doc file download reply can be seen:
Tourists, if you want to see the hidden content of this post, pleaseReply





Previous:Tencent video ads are very annoying I teach you to get rid of 60-second ads
Next:IoT wireless transceivers
Posted on 3/23/2017 1:04:27 PM |
Thank you landlord for sharingThank you landlord for sharingThank you landlord for sharingThank you landlord for sharing
Posted on 9/11/2017 10:54:10 PM |
ssdsdasdsdsadasdsadsad
Posted on 9/29/2017 4:29:01 PM |
Yes, you can package and send downloads
Posted on 3/15/2018 8:01:51 PM |
Test yourself
Posted on 3/31/2019 11:01:53 PM |
Thank you, big guy, do you have an answer
Posted on 5/10/2019 8:47:02 AM |
5641651265165
Posted on 9/23/2019 4:40:56 AM |
Previous:Tencent video ads are very annoying I teach you to remove 60-second ads
Next: Internet of Things wireless reception
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com