Which two will compile, and can be run successfully using the command: Java fred1 hello walls

Which two will compile, and can be run successfully using the command:
Java fred1 hello walls

Which two will compile, and can be run successfully using the command:
Java fred1 hello walls

A.
class Fred1{
public static void main (String args) {
System.out.println(args[1]);
}
}
It compiles without error.

B.
class Fred1{
public static void main (String [] args) {
System.out.println(args[2]);
}
}
It does not compile because an abstract class cannot have private methods.

C.
class Fred1 {
public static void main (String [] args) {
System.out.println (args);
}
}
Prints out: [Ljava.lang.String;@39341183
It does not compile because an abstract class cannot have instance variables.

D.
class Fred1 {
public static void main (String [] args) {
System.out.println (args [1]);
}
}
Prints out: walls
QUESTION 62
Given:
public abstract class Wow {
private int wow;
public wow (int wow) {
this.wow = wow;
}
public void wow () {}
private void wowza () {}
}
What is true about the class Wow?
It does not compile because an abstract class must have at least one abstract method.

C.
class Fred1 {
public static void main (String [] args) {
System.out.println (args);
}
}
Prints out: [Ljava.lang.String;@39341183
It does not compile because an abstract class cannot have instance variables.

D.
class Fred1 {
public static void main (String [] args) {
System.out.println (args [1]);
}
}
Prints out: walls
QUESTION 62
Given:
public abstract class Wow {
private int wow;
public wow (int wow) {
this.wow = wow;
}
public void wow () {}
private void wowza () {}
}
What is true about the class Wow?
It does not compile because an abstract class must have at least one abstract method.

A.
class Fred1{
public static void main (String args) {
System.out.println(args[1]);
}
}
It compiles without error.

B.
class Fred1{
public static void main (String [] args) {
System.out.println(args[2]);
}
}
It does not compile because an abstract class cannot have private methods.

C.
class Fred1 {
public static void main (String [] args) {
System.out.println (args);
}
}
Prints out: [Ljava.lang.String;@39341183
It does not compile because an abstract class cannot have instance variables.

D.
class Fred1 {
public static void main (String [] args) {
System.out.println (args [1]);
}
}
Prints out: walls
QUESTION 62
Given:
public abstract class Wow {
private int wow;
public wow (int wow) {
this.wow = wow;
}
public void wow () {}
private void wowza () {}
}
What is true about the class Wow?
It does not compile because an abstract class must have at least one abstract method.

E.
It does not compile because an abstract class must have a constructor with no arguments.

Explanation:
Throws java.lang.ArrayIndexOutOfBoundsException: 2
at certquestions.Fred1.main(Fred1.java:3)
An abstract class is a class that is declared abstract—it may or may not include
abstract methods (not B, not D). Abstract classes cannot be instantiated, but they can be
subclassed.
The code compiles with a failure for line ‘public wow (int wow) {‘



Leave a Reply 1

Your email address will not be published. Required fields are marked *


Sandeep

Sandeep

There seem to be 2 questions merged into 1. This question need modification.