Tag: programming languages

Questions Related to programming languages

  1. A 12

  2. B 012

  3. C 10

  4. D 10.0


Correct Option: C
Explanation:

To solve this question, the user needs to know the basics of Java programming language. The code creates an object of the Oct class and then calls the amethod() method, which initializes an integer variable oi with 012 and prints its value to the console.

In Java, leading zero in an integer literal denotes an octal (base-8) number. Therefore, the value 012 is an octal number that represents the decimal value 10.

So, the correct answer is:

The Answer is: C. 10

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

18 You have a public class called myclass with the main method defined as follows public static void main(String parm[]){ System.out.println(parm[0]); } If you attempt to compile the class and run the program as follows java myclass hello What will happen?

  1. a. Compile time error, main is not correctly defined

  2. b. Run time error, main is not correctly defined

  3. c. Compilation and output of java

  4. d. Compilation and output of hello


Correct Option: D

19 Read this piece of code carefully if("String".toString() == "String") System.out.println("Equal"); else System.out.println("Not Equal");

  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