0

programming languages Online Quiz - 322

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

12 You have these files in the same directory. What will happen when you attempt to compile and run Class1.java if you have not already compiled Base.java //Base.java package Base; class Base{ protected void amethod(){ System.out.println("amethod"); }//End of amethod }//End of class base package Class1; //Class1.java public class Class1 extends Base{ public static void main(String argv[]){ Base b = new Base(); b.amethod(); }//End of main }//End of Class1

  1. a. Compile Error: Methods in Base not found

  2. b. Compile Error: Unable to access protected method in base class

  3. c. Compilation followed by the output "amethod"

  4. d. Compile error: Superclass Class1.Base of class Class1.Class1 not found


Correct Option: D

13 Which of the following statements are true?

  1. a. The elements in a Java array can only be of primitive types, not objects

  2. b. Arrays elements are initialized to default values wherever they are created using the keword new

  3. c. An array may be dynamically resized using the setSize method

  4. d. You can find out the size of an array using the size method


Correct Option: B
  1. a float f=1/3;

  2. b int i=1/3;

  3. c float f=1.01;

  4. d double d=999d;


Correct Option: A,B,D
  1. A System.out.println(1+1);

  2. B int i=2+'2';

  3. C String s="on"+'one';

  4. D byte b=255;


Correct Option: A,B
  1. a. All of the variables in an interface are implicitly static

  2. b. All of the variables in an interface are implicitly final

  3. c. All of the methods in an interface are implicitly abstract

  4. d. A method in an interface can access class level variables


Correct Option: A,B,C
  1. a. An interface can only contain method and not variables

  2. b. Interfaces cannot have constructors

  3. c. A class may extend only one other class and implement only one interface

  4. d. Interfaces are the Java approach to addressing its lack of multiple inheritance, but require implementing classes to create the functionality of the Interfaces.


Correct Option: B
  1. a. the code will compile an print "Equal".

  2. b. the code will compile an print "Not Equal".

  3. c. the code will cause a compiler error.

  4. d.


Correct Option: B
  1. a. the code will compile an print "Equal".

  2. b. the code will compile an print "Not Equal".

  3. c. the code will cause a compiler error

  4. d.


Correct Option: A

Given: 11. static classA { 12. void process() throws Exception { throw new Exception(); } 13. } 14. static class B extends A { 15. void process() { System.out.println(”B “); } 16. } 17. public static void main(String[] args) { 18.A a=new B(); 19. a.process(); 20.} What is the result?

  1. B

  2. The code runs with no output.

  3. An exception is thrown at runtime.

  4. Compilation fails because of an error in line 15.

  5. Compilation fails because of an error in line 18.

  6. Compilation fails because of an error in line 19.


Correct Option: F

Given: 10. interface Foo {} 11. class Alpha implements Foo { } 12. class Beta extends Alpha {} 13. class Delta extends Beta { 14. public static void main( String[] args) { 15. Beta x = new Beta(); 16. // insert code here 17. } 18. } Which code, inserted at line 16, will cause a java.lang.ClassCastException?

  1. Alpha a = x;

  2. Foo f= (Delta)x;

  3. Foo f= (Alpha)x;

  4. Beta b = (Beta)(Alpha)x;


Correct Option: B

Perl was develped by

  1. Larry floor

  2. Larry wall

  3. Denise Ritche

  4. Micheal Jackson


Correct Option: B
  1. An interpreter language

  2. A compiler language

  3. Partial compiler and interpreter language

  4. An Indian language


Correct Option: C

File extension for a perl program is

  1. .pl

  2. .per

  3. .perl

  4. .prl


Correct Option: A
- Hide questions