Java and Perl Programming Fundamentals

Test your knowledge of Java and Perl programming languages including data types, methods, inheritance, serialization, arrays, hashes, and language-specific features.

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Perl has

  1. 8 data types
  2. 7 data types
  3. 16 data types
  4. No special data types
Question 2 Multiple Choice (Single Answer)

Scalar Variable in perl is preceded by a

  1. $
  2. #
  3. @
  4. None of the above
Question 3 Multiple Choice (Single Answer)

A Hash variable in perl is preceded by a

  1. $
  2. %
  3. #
  4. @
Question 4 Multiple Choice (Single Answer)

What are the functions used to add elements in an array

  1. Push and unshift
  2. Push and shift
  3. Pop and push
  4. Shift and unshift
Question 5 Multiple Choice (Single Answer)

Which function is used to remove a key – value pair from hash

  1. Remove
  2. Unhash
  3. Delete
  4. Rub
Question 6 Multiple Choice (Multiple Answers)

From below , which are all available as default options in perl

  1. -v
  2. -w
  3. -k
  4. -d
Question 7 Multiple Choice (Single Answer)

PERL is an acronym of

  1. Powerful Encryption and Report Language
  2. Practical Extraction and Report Language
  3. Practical Emotional and Rational Language
  4. Powerful Execution and Riding Language
Question 8 Multiple Choice (Multiple Answers)

Select two methods that correctly overload the following method? (Assume that all necessary packages have been imported). byte bMethod(short i) throws Exception {...}

  1. int bMethod(int i) throws IOException{...}
  2. protected int bMethod(short s) throws FileNotFoundException{...}
  3. private String aMethod(byte b,short s) throws Exception{...}
  4. char bMethod(String s) throws RuntimeException{...}
  5. int bMethod(short sh){...}
Question 9 Multiple Choice (Multiple Answers)

Which of the following statements are infinite loops? Select two correct answers

  1. for(int i=10;i>0;i-=-2);
  2. for(int i=0;i<012;i=i++);
  3. for(int i=0;i<0;i--);
  4. for(int i=0;(i++^--i)==0;i++);
  5. for(int i=010;i==10;i+=0);
Question 10 Multiple Choice (Multiple Answers)

Select two methods that correctly override the following method? (Assume that all necessary packages have been imported). protected int aMethod(int i) throws IOException {...}

  1. int aMethod(int i) throws IOException{...}
  2. protected int aMethod(int i) throws FileNotFoundException{...}
  3. public int aMethod(int i) throws Exception{...}
  4. public int aMethod(byte i) throws IOException{...}
  5. protected int aMethod(int i) throws IOException,FileNotFoundException{...}
Question 11 Multiple Choice (Multiple Answers)

Select three correct statements.

  1. A static method may override another static method.
  2. A static method cannot override a non-static method.
  3. A non-static method cannot override a static method.
  4. A non-static method may be overloaded by a static method.
  5. A synchronized method cannot be overridden.
Question 12 Multiple Choice (Single Answer)

Command to execute a compiled java programs is

  1. run
  2. execute
  3. javac
  4. java
Question 13 Multiple Choice (Single Answer)

Which of the following denote methods of HttpServlet class?

  1. doGet()
  2. doTrace()
  3. doOptions()
  4. All the Above
Question 14 Multiple Choice (Single Answer)

Which of the following helps in garbage collection?

  1. final
  2. finally
  3. finalize
  4. finalizer
Question 15 Multiple Choice (Single Answer)

What is the output of the following code? import java.util.*; public class Example { final Vector v; public Example() { } }

  1. The above code will not compile, Vector v is not initialized.
  2. The above code will compile and throw a Runtime Exception
  3. The above code will compile and not throw any Exception during runtime. V is initialized to null
  4. None of the Above.
Question 16 Multiple Choice (Single Answer)

What does the following expression return? Math.max(Float.POSITIVE_INFINITY,Double.POSITIVE_INFINITY);

  1. Float.POSITIVE_INFINITY
  2. Double.POSITIVE_INFINITY
  3. runtime Exception
  4. None of the Above
Question 17 Multiple Choice (Single Answer)

The class that inherits is called a

  1. superclass
  2. subclass
  3. instance class
  4. None of the Above
Question 18 Multiple Choice (Single Answer)

The process of writing the state of an object to a byte stream is called as

  1. Deserialization
  2. Serialization
  3. Interface
  4. None
Question 19 Multiple Choice (Single Answer)

What is the output of the following piece of code? if(" String ".trim() == "String") System.out.println("Welcome"); else System.out.println("Good Bye");

  1. The code will compile and print "Welcome"
  2. The code will compile and print "Good Bye"
  3. The code will cause a compiler error
  4. None of the Above
Question 20 Multiple Choice (Single Answer)

What is the number of bytes used by Java primitive long?

  1. The number of bytes is compiler dependent
  2. 2
  3. 4
  4. 8