Oracle sual nümunələri Sual nümunələri

1Z0-803 (OCA 7) imtahan sualı nümunələri (Oracle)

1z0-803 sample exam questions
Written by Mushfiq Mammadov

1. Given:

public class Calculator {
[nbsp count=4]int num = 100;
[nbsp count=4]public void calc(int num) {
[nbsp count=8]this.num = num * 10;
[nbsp count=4]}
[nbsp count=4]public void printNum() {
[nbsp count=8]System.out.println(num);
[nbsp count=4]}
[nbsp count=4]public static void main(String[] args) {
[nbsp count=8]Calculator obj = new Calculator();
[nbsp count=8]obj.calc(2);
[nbsp count=8]obj.printNum();
[nbsp count=4]}
}

What is the result?

A) 20
B) 100
C) 1000
D) 2

 

2. Given:

public class MyStuff {
[nbsp count=4]String name;
[nbsp count=4]MyStuff(String n) {
[nbsp count=8]name = n;
[nbsp count=4]}
[nbsp count=4]public static void main(String[] args) {
[nbsp count=8]MyStuff m1 = new MyStuff("guitar");
[nbsp count=8]MyStuff m2 = new MyStuff("tv");
[nbsp count=8]System.out.println(m2.equals(m1));
[nbsp count=4]}
[nbsp count=4]public boolean equals(Object o) {
[nbsp count=8]MyStuff m = (MyStuff) o;
[nbsp count=8]if (m.name != null) {
[nbsp count=12]return true;
[nbsp count=8]}
[nbsp count=5]return false;
[nbsp count=4]}
}

What is the result?

A) The output is true and MyStuff fulfills the Object.equals() contract.
B) The output is false and MyStuff fulfills the Object.equals() contract.
C) The output is true and MyStuff does NOT fulfill the Object.equals() contract.
D) The output is false and MyStuff does NOT fulfill the Object.equals() contract.

 

3. Given:

import java.util.*;
public class App {
[nbsp count=4]public static void main(String[] args) {
[nbsp count=8]List p = new ArrayList();
[nbsp count=8]p.add(7);
[nbsp count=8]p.add(1);
[nbsp count=8]p.add(5);
[nbsp count=8]p.add(1);
[nbsp count=8]p.remove(1);
[nbsp count=8]System.out.println(p);
[nbsp count=4]}
}

What is the result?

A) [7, 1, 5, 1] B) [7, 5, 1] C) [7, 5] D) [7, 1]

 

4. Given:

public class MyLoop {
[nbsp count=4]public static void main(String[] args) {
[nbsp count=8]String[] sa = {"tom ", "jerry "};
[nbsp count=8]for (int x = 0; x < 3; x++) {
[nbsp count=12]for (String s : sa) {
[nbsp count=16]System.out.print(x + " " + s);
[nbsp count=16]if (x == 1) {
[nbsp count=20]break;
[nbsp count=16]}
[nbsp count=12]}
[nbsp count=8]}
[nbsp count=4]}
}

What is the result?

A) 0 tom 0 jerry 1 tom 1 jerry
B) 0 tom 0 jerry 2 tom 2 jerry
C) 0 tom 0 jerry 1 tom 2 tom 2 jerry
D) 0 tom 0 jerry 1 tom 1 jerry 2 tom 2 jerry

 

5. Given:

interface Rideable { String getGait(); }
public class Camel implements Rideable {
[nbsp count=4]int weight = 2;
[nbsp count=4]String getGait() { return " mph, lope"; }
[nbsp count=4]void go(int speed) {
[nbsp count=8]++speed; weight++;
[nbsp count=8]int walkrate = speed * weight;
[nbsp count=8]System.out.print(walkrate + getGait());
[nbsp count=4]}
[nbsp count=4]public static void main(String[] args) {
[nbsp count=8]new Camel().go(8);
[nbsp count=4]}
}

What is the result?

A) 16 mph, lope
B) 24 mph, lope
C) 27 mph, lope
D) Compilation fails.

 

6.Given:

class Alpha {
[nbsp count=4]String getType() {
[nbsp count=8]return "alpha";
[nbsp count=4]}
}
class Beta extends Alpha {
[nbsp count=4]String getType() {
[nbsp count=8]return "beta";
[nbsp count=4]}
}
public class Gamma extends Beta {
[nbsp count=4]String getType() {
[nbsp count=8]return "gamma";
[nbsp count=4]}
[nbsp count=4]public static void main(String[] args) {
[nbsp count=8]Gamma g1 = new Alpha();
[nbsp count=8]Gamma g2 = new Beta();
[nbsp count=8]System.out.println(g1.getType() + " " + g2.getType());
[nbsp count=4]}
}

What is the result?

A) alpha beta
B) beta beta
C) gamma gamma
D) Compilation fails.

 

7. Given:

class Feline {
[nbsp count=4]public String type = "f ";
[nbsp count=4]public Feline() {
[nbsp count=8]System.out.print("feline ");
[nbsp count=4]}
}

public class Cougar extends Feline {
[nbsp count=4]public Cougar() {
[nbsp count=8]System.out.print("cougar ");
[nbsp count=4]}
[nbsp count=4]void go() {
[nbsp count=8]type = "c ";
[nbsp count=8]System.out.print(this.type + super.type);
[nbsp count=4]}
[nbsp count=4]public static void main(String[] args) {
[nbsp count=8]new Cougar().go();
[nbsp count=4]}
}

What is the result?

A) cougar c f
B) feline cougar c c
C) feline cougar c f
D) Compilation fails.

 

Cavablar
1. A
2. C
3. B
4. C
5. D
6. D
7. B

 

Mənbə: Oracle, Exam 803: Java SE 7

About the author

Mushfiq Mammadov

Leave a Comment


The reCAPTCHA verification period has expired. Please reload the page.

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.