0

programming languages Online Quiz - 296

Description: programming languages Online Quiz - 296
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

Given: 1. public interface A { 2. String DEFAULT_GREETING = “Hello World”; 3. public void method1(); 4. } A programmer wants to create an interface called B that has A as its parent. Which interface declaration is correct?

  1. public interface B extends A { }

  2. public interface B implements A {}

  3. public interface B instanceOf A {}

  4. public interface B inheritsFrom A { }


Correct Option: A

Given: 1. class TestA { 2. public void start() { System.out.println(”TestA”); } 3. } 4. public class TestB extends TestA { 5. public void start() { System.out.println(”TestB”); } 6. public static void main(String[] args) { 7. ((TestA)new TestB()).start(); 8. } 9. } What is the result?

  1. TestA

  2. TestB

  3. Compilation fails.

  4. An exception is thrown at runtime.


Correct Option: B

Given: 11. public abstract class Shape { 12. int x; 13. int y; 14. public abstract void draw(); 15. public void setAnchor(int x, int y) { 16. this.x = x; 17. this.y = y; 18. } 19. } and a class Circle that extends and fully implements the Shape class. Which is correct?

  1. Shape s = new Shape(); s.setAnchor(10,10); s.draw();

  2. Circle c = new Shape(); c.setAnchor(10,10); c.draw();

  3. Shape s = new Circle(); s.setAnchor(10,10); s.draw();

  4. Shape s = new Circle(); s->setAnchor(10,10); s->draw();


Correct Option: C
  1. . public class Employee extends Info implements Data { public void load() { /do something/ }

  2. public class Employee implements Info extends Data { public void load() { /do something/ }

  3. public class Employee extends Info implements Data { public void load() { /*do something */ }

  4. public class Employee implements Info extends Data { public void Data.load() { /*d something */ }


Correct Option: A
  1. public class Circle implements Shape { private int radius;

  2. public abstract class Circle extends Shape { private int radius;

  3. public class Circle extends Shape {

  4. public abstract class Circle implements Shape {


Correct Option: B,C

public class xyz { public static void main(String args[]) { for(int i = 0; i < 2; i++) { for(int j = 2; j>= 0; j--) { if(i == j) break; System.out.println("i=" + i + " j="+j); } } } } A) i=0 j=0 B) i=0 j=1 C) i=0 j=2 D) i=1 j=0 E) i=1 j=1 F) i=1 j=2 G) i=2 j=0 H) i=2 j=1 I) i=2 j=2

  1. B,C

  2. A,I,F

  3. B,C,F

  4. None of the above


Correct Option: C

Select the one correct answer. Which method defined in Integer class can be used to convert an Integer object to primitive int type. A) valueOf B) intValue C) getInt D) getInteger

  1. A

  2. C

  3. D

  4. None of the Above


Correct Option: D
  1. if((i == 0) || (j/i == 1))

  2. if((i == 0) | (j/i == 1))

  3. if((i != 0) && (j/i == 1))

  4. if((i != 0) & (j/i == 1))


Correct Option: B,D

The maximum combined length of the command line arguments including the spaces between adjacent arguments is

  1. 128 characters

  2. 256 characters

  3. 67 characters

  4. It may vary from one operating system to another


Correct Option: D

What would be the output of the following program? main() { unsigned char i = 0x80; printf("\n%d", i<<1); }

  1. 0

  2. 256

  3. 100

  4. None of the above


Correct Option: B
- Hide questions