OAmaster
— / 20已做

What feature allows different methods to have the same name and arguments type, but a different implementation is called?

  • overloading
  • overriding <-
  • Java does not permit methods with same name and type signature
  • None of the above
1. Input two integers: a, b.
2. Initialize the value of x to a and the value of y to b.
3. If x > y then set x to x - y.
4. If x < y then set y to y - x.
5. Repeat steps 3 and 4 until x = y.
6. Output x (or y) and halt.

What will this algorithm output in step 6 if we begin with a = 2437, b = 875?

  • 0 / 1 <- / 2 / 3 / 875 / 2437

Which of the following handles function calls?

  • The data heap
  • The stack <-
  • The processor's registers
  • The main memory
  • The system calls

What does the following function print?

func(int i) {
 if (i % 2) return 0;
 else return 1;
}
main() {
 int i = 3;
 i = func(i);
 i = func(i);
 printf("%d", i);
}
  • 3 / 1 <- / 0 / 2

Trace: i=3 (odd) → func returns 0; then i=0 (even) → func returns 1.

Which statement is correct for a method which is overriding public void add(int a) { ... }?

  • the overriding method must return void <-
  • the overriding method must return int
  • the overriding method can return whatever it likes
public int divide(int a, int b) {
    int c = -1;
    try {
        c = a / b;
    } catch (Exception e) {
        System.err.print("Exception ");
    } finally {
        System.err.println("Finally ");
    }
    return c;
}
  • Exception Finally <-

Identify the status code returned after a resource is successfully deleted using the HTTP DELETE method.

  • 201 / 202 / 200 / 402 / 409 / None of these <-

Identify the item that is not an HTTP verb.

  • GET / POST / DELETE / REMOVE <- / PUT / PATCH

Which testing is used for a program's individual components functionality testing?

  • Functionality Testing
  • Unit Testing <-
  • Security Testing / Smoke Testing / Regression Testing

Which is NOT true of JavaScript?

  • JavaScript is case sensitive
  • Semicolons at the end of JavaScript statements are required <-
  • JavaScript statements can be grouped together in blocks
  • JavaScript is loosely typed
  • var items = ["Orange", "Apple"]; <-
  • var items = {"Orange", "Apple"};
  • var items = new array("Orange", "Apple");
  • var items[] = {"Orange", "Apple"};
main() {
 char str1[] = "Hello";
 char str2[] = "World";
 str1 = str2;
 printf("%s %s", str1, str2);
}
  • Compiler error <-
  • Hello World / World Hello / World World

In a hash table where both keys and values are integers, which iteration output is valid (Key=a, Value=b)?

  • Key=1,V=10 / Key=2,V=10 / Key=3,V=10 / Key=4,V=10 <-
  • 100 / 200 / 400 / 500 <-

5xx = server error; 4xx = client error.

What is the output of the following code?

#include <stdio.h>
void main() {
 int s = 0;
 while (s++ < 10) {
 if (s < 4 && s < 9) continue;
 printf("\n%d\t", s);
 }
}
  • 1 2 3 4 5 6 7 8 9 / 1 2 3 10 / 4 5 6 7 8 9 10 <- / 4 5 6 7 8 9

The compound s < 4 && s < 9 reduces to s < 4, so s = 1, 2, 3 are skipped; s = 4..10 are printed.

public class X {
    public static void main(String[] args) {
        try {
            badMethod();
            System.out.print("A");
        } catch (Exception ex) {
            System.out.print("B");
        }
        finally {
            System.out.print("C");
        }
        System.out.print("D");
    }
    public static void badMethod() {}
}
  • AC / BC / ACD <- / ABCD

Which is NOT a primitive datatype in JavaScript?

  • Array <- / Number / String / Boolean

In what order will the numbers 1-4 be logged to the console when the code below is executed?

(function() {
 console.log(1);
 setTimeout(function(){ console.log(2); }, 1000);
 setTimeout(function(){ console.log(3); }, 0);
 console.log(4);
})();
  • 1 2 3 4 / 4 3 2 1 / 1 4 3 2 <- / 1 3 4 2

Sync log fires first (1, 4); both setTimeout callbacks go to the macrotask queue — the 0ms one fires before the 1000ms one (3, then 2).

What will be the output of this Java program?

class SSBool {
    public static void main(String[] args) {
        boolean b1 = true, b2 = false, b3 = true;
        if (b1 & b2 | b2 & b3 | b2)            // Line 8
            System.out.print("ok ");
        if (b1 & b2 | b2 & b3 | b2 | b1)       // Line 10
            System.out.println("dokey");
    }
}
  • ok / dokey <- / ok dokey / compilation fails

Line 8 evaluates to false (no ok); line 10 ends with | b1 which is true, so dokey prints.

Which is true about a declaration and a definition of a variable?

  • Both can occur multiple times, but a declaration must occur first.
  • There is no difference between them.
  • A definition occurs once, but a declaration may occur many times. <-
  • A declaration occurs once, but a definition may occur many times.
  • Both can occur multiple times, but a definition must occur first.
Pro 会员

解锁全部 17 道题的解法

题面你已经看到了 — 解法 + 三语代码 + 复杂度推导 + 边界讨论, Pro 解锁.

Pro 解锁全部
  • 📚1000+ 道真实北美 OA, Python / Java / C++ 三语题解
  • 📊个人 dashboard + 进度可视化 + 14 天活跃图
  • 📝题目笔记跨设备同步 + 个人复盘库
  • 🔓随时取消下次续费, Stripe Customer Portal 自助管理
$12/月($98/年, 一次付清省 32%)

≈ 北美 SWE 工资 10 分钟 · LeetCode Premium $35/月 的 23%