`
abalone
  • 浏览: 130718 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

problem

    博客分类:
  • java
阅读更多
5. Given:
public class Foo {
    public static void main (String [] args)  {
        StringBuffer a = new StringBuffer("A");
        StringBuffer b = new StringBuffer ("B");
        operate (a,b);
        System.out.println(a + "," +b);
    }
    static void operate(StringBuffer x, StringBuffer y) {
        x.append(y);
        y = x;
    }
}

===================== http://www.opcol.com/

6. Given:
public class Test {
    public static void stringReplace (String text) {
        text = text.replace('j', 'i');
    }
    public static void bufferReplace (StringBuffer text) {
        text = text.append ('c');
    }
    public static void main (String args[]) {
        String textString = new String ("java");
        StringBuffer textBuffer = new StringBuffer("java");
        stringReplace(textString);
        bufferReplace(textBuffer);
        System.out.println (textString + textBuffer);
    }
}

=======================
public class Test {
    public static void add3(Integer i) {
        int val = i.intValue();
        val += 3;
        i = new Integer(val);
    }
    public static void main(String args[]){
        Integer  i = new Integer(0);
        add3 (i);
    System.out.println (i.intValue());
    }
}
====================
18. Which three are valid declarations of a float? (Choose Three)
A. float foo = -1;
B. float foo = 1.0;
C. float foo = 42e1;
D. float foo = 2.02f;
E. float foo = 3.03d;
F. float foo = 0x0123;
========================
15. Given:
interface Foo {
    int k = 0;          //line 2
}
public class Test implements Foo {
    public static void main(String args[]) {
        int i;
        Test test = new Test();
        i = test.k;     //8
        i = Test.k;     //9
        i = Foo.k;      //10
    }
}
============================
22. Given:
public class Foo {
    public static void main (String[] args) {
        String s;
        System.out.println (“s=” + s);
    }
}
=============================
26. Given:
public class test{
    public int aMethod(){
        static int i=0;
        i++;
        return i;
    }
    public static void main (String args[]){
        test test = new test();
        test.aMethod();
        int j = test.aMethod();
        System.out.printIn(j);
    }
}
What is the result?
A. Compilation will fail.
B. Compilation will succeed and the program will print “0”.
C. Compilation will succeed and the program will print “1”.
D. Compilation will succeed and the program will print “2”.

==========================
27. Given:
class Super {
    public float getNum() {return 3.0f;}
}
public class Sub extends Super {
    //line 5
)
Which method, placed at line 5, will cause a compiler error?
A. public float getNum() { return 4.0f; }
B. public void getNum() {}
C. public void getNum(double d) {}
D. public double getNum(float d) {retrun 4.0f; }
==========================
29. Given:
byte [] array1, array2[];
byte array3 [][];
byte[][] array4;
If each array has been initialized, which statement will cause a compiler error?
A. array2 = array1;
B. array2 = array3;
C. array2 = array4;
D. both A and B
E. both A and C
F. both B and C
=========================
52. Given:
public class Test {
    public static String output = "";
    public static void foo(int i) {
        try {
            if(i==1) {
                throw new Exception ();
            }
            output += "1";
        } catch(Exception e) {
            output += “2”;
            return;
        } finally (
            output += “3”;
        }
        output += “4”;
    }
    public static void main (String args[])  (
        foo(0);
        foo(1);
        //line 24
    }
)
=========================
53. Given:
public class Foo implements Runnable {      //line 1
    public void run (Thread t) {            //line 2
        System.out.println("Running.");
    }
    public static void main (String[] args) {
        new Thread(new Foo()).start();
    }
}
========================
59. Given:
public class X implements Runnable {
    private int x;
    private int y;
    public static void main(String[] args) {
        X that = new X();
        (new Thread(that)).start();         //line 7
        (new Thread(that)).start();         //line 8
    }
    public synchronized void run{} {        //line 11
        for (;;) {
            x++;
            y++;
            System.out.println(“x = “ +  x  + “, y = “ + y);
        }
    }  
}
===============================
61. Given:
public class SyncTest{
    public static void main(String[] args)  {
        final StringBuffer s1= new StringBuffer();
        final StringBuffer s2= new StringBuffer();
        new Thread () {
            public void run() {
                synchronized(s1) {
                    s2.append(“A”);
                    synchronized(s2) {
                        s2.append(“B”);
                        System.out.print(s1);
                        System.out.print(s2);
                        }
                }
            }
        }.start();
        new Thread() {
            public void run() {
                synchronized(s2) {
                    s2.append(“C”);
                    synchronized(s1)
                        s1.append(“D”);
                        System.out.print(s2);
                        System.out.print(s1);
                    }
                }
            }
        }.start();
    }
}
Which two statements are true? (Choose Two)
A. The program prints “ABBCAD”
B. The program prints “CDDACB”
C. The program prints “ADCBADBC”
D. The output is a non-deterministic point because of a
possible deadlock condition
E. The output is dependent on the threading model of the
system the program is running on.
============================
68. Given:
class A {
    public int getNumber(int a) {
        return a + 1;
    }
}
class B extends A {
    public int getNumber(int a) {
        return a + 2;           //line 8
    }
    public static void main (String args[])  {
        A a = new B();          //line 13
        System.out.println(a.getNumber(0));     //line 14
    }
}
What is the result?
A. Compilation succeeds and 1 is printed.
B. Compilation succeeds and 2 is printed.
C. An error at line 8 causes compilation to fail.
D. An error at line 13 causes compilation to fail.
E. An error at line 14 causes compilation to fail.
Answer: B
========================















分享到:
评论

相关推荐

    Problem Solving with C++, 10th Global Edition

    Problem Solving with C++, Global Edition by Walter Savitch (author) (Author) Pages:1117 出版社: Pearson Education Limited; 10th edition edition (November 20, 2017) Language: English ISBN-10: ...

    Problem Solving with C++ 7th edition

    《Problem Solving with C++ 第七版》是由Walter Savitch所著的一本经典的C++编程教材。本书通过大量的实例和项目练习,详细讲解了C++程序设计的基础知识、编程思想和技巧。本书内容详实,覆盖面广,从最基本的编译...

    Problem_C_Data.rar

    Problem_C_Data.zip The three data sets provided contain product user ratings and reviews extracted from the Amazon Customer Reviews Dataset thru Amazon Simple Storage Service (Amazon S3). hair_dryer....

    C++ Programming From Problem Analysis to Program Design 5th Edition

    W ELCOME TO THE F IFTH EDITION OF C++ Programming: From Problem Analysis to Program Design. Designed for a first Computer Science (CS1) C++ course, this text provides a breath of fresh air to you and ...

    Problem_C_Data.zip

    "Problem_C_Data.zip" 是一个压缩包文件,包含2020年美国数学建模竞赛(简称美赛)C题的题目及相应的原始数据。美赛是一项国际性的数学建模竞赛,每年吸引众多学生参与,旨在提升参赛者的数学、数据分析和解决实际...

    《Approaching (Almost) Any Machine Learning Problem》

    Approaching (Almost) Any Machine Learning Problem是一本旨在帮助读者掌握机器学习问题解决方法的书籍。这本书涵盖了机器学习的基本概念、模型选择、数据预处理、特征工程、模型评估等多方面的知识点。 机器学习...

    Computer-Based.Problem.Solving.Process

    Title: Computer-Based Problem Solving Process Author: Teodor Rus Length: 350 pages Edition: 1 Language: English Publisher: World Scientific Publishing Company Publication Date: 2015-05-30 ISBN-10: ...

    Problem Solving with Algorithms and Data Structures using Python 中文版

    Problem Solving with Algorithms and Data Structures using Python 中文版 PythonDS Cover By Brad Miller and David Ranum, Luther College ---------------------------------------------------- 本 PDF 基于...

    master page search problem

    在这个特定的问题“master page search problem”中,我们可能遇到的是在使用Master Page时搜索功能出现的问题。ViewData是ASP.NET MVC框架中的一个特性,用于在控制器和视图之间传递数据,而JavaScript则是客户端...

    Problem Solving with Algorithms and Data Structures using Python

    "Problem Solving with Algorithms and Data Structures using Python"是一本专注于利用Python语言学习算法和数据结构的教材,其第二版的网站提供了丰富的学习资源,包括实例、练习和解决方案,旨在帮助开发者深入...

    C++ Programming From Problem Analysis to Program Design 8th

    《C++ Programming From Problem Analysis to Program Design 8th》是一本深入浅出的C++编程教程,由资深计算机教育家Zelle撰写。该书旨在帮助读者从问题分析到程序设计的整个过程,全面掌握C++语言。最新版更新至...

    Spring Recipes A Problem-Solution Approach.pdf

    总之,《Spring Recipes A Problem-Solution Approach》是一本非常实用的Spring框架学习资料,对于希望深入了解Spring 2.5及其在企业级Java应用开发中的应用的开发者来说,本书无疑是不可或缺的参考书目。

    C# Programming From Problem Analysis to Program Design(4th)

    《C# Programming From Problem Analysis to Program Design》第四版是一本深入浅出的C#编程教程,旨在引导读者从问题分析到程序设计的全过程。这本书专为初学者和有一定经验的程序员设计,通过全面覆盖C#语言的核心...

    Problem Solving with C++(9th) 无水印pdf

    Problem Solving with C++(9th) 英文无水印pdf 第9版 pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请...

    Boxing Problem_三维装箱_三维装箱算法_三维装箱问题_Boxingproblem_退火

    在物流、仓储及制造业等领域,如何高效地利用有限的空间来装载物品是一个重要的优化问题,这就是所谓的“三维装箱问题”(3D Bin Packing Problem)。它涉及到如何在有限数量的三维箱子中,以最小的空间浪费来容纳...

    node-problem-detector-0.8.7.tar

    node-problem-detector 镜像包 v0.8.7 版本

    Problem Solving in Data Structures & Algorithms Using C# azw3

    Problem Solving in Data Structures & Algorithms Using C# 英文azw3 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除

Global site tag (gtag.js) - Google Analytics