Question

What is the output ot tollowing program: public class Test public static void main(StringO args) A a new A0. a method B0: class A public A0{ System out printin(As constructor is executed): public void methodA0 System out printin (methodA is executed): public void methodAB0{ System out printin (As methodAB is executed class B extends A private int num 0: public B 0{ super0: System out printin (Bs constructor is executed public B (int n) num System out printin(Bs constructor is executed public void method System out printin( um is num System.out printin methodB is ececuted): public void methodAB) System.out printin (Bs methodAB is executed O A-As constructor is executed num is 0 method B is O B. As constructor is executed methodA is executed OC. Compiling time error because methodB is not defined in Class A,

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The answer is : Option C. Compiling time error because "methodB" is not defined in Class A

The method 'methodB()' is available in Class B. We wont get this error, if Class A extends Class B.

Add a comment
Know the answer?
Add Answer to:
What is the output of following program: public class Test{ public static void main(String[] args) {...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. What is the output when you run printIn()? public static void main(String[] args) { if...

    1. What is the output when you run printIn()? public static void main(String[] args) { if (true) { int num = 1; if (num > 0) { num++; } } int num = 1; addOne(num); num = num - 1 System.out.println(num); } public void addOne(int num) { num = num + 1; } 2. When creating an array for primitive data types, the default values are: a. Numeric type b. Char type c. Boolean type d. String type e. Float...

  • what is output public static void main(String args) Scanner keyboard new Scanner(System.in); int u 14; int...

    what is output public static void main(String args) Scanner keyboard new Scanner(System.in); int u 14; int w 0; int x; int y 5; float z = 6.1 System.out.print("Enter y: "); x keyboard.nextint); System.out.println('y'); System.out.println(x); System.out.println(w*3); x- x+(int)z; System.out.println(x); 0 System.out.println(u); System.out.,println(u); System.out.println"x In" + y); System.out.print(y + z); ) liclosing main method 1 liclosing class header

  • What output is produced by the following program? public class MysteryNums public static void main(String[] args)...

    What output is produced by the following program? public class MysteryNums public static void main(String[] args) - int x = 12; int y = x - 3; 3, sentence (y, x + y); . public static void sentence (int numi, int num2) { 4: System.out.println(num1 + " + num2);

  • Analyze the following code: public class Test { private int t; public static void main(String[] args)...

    Analyze the following code: public class Test { private int t; public static void main(String[] args) { int x; System.out.println(t); } } The variable t is private and therefore cannot be accessed in the main method. The program compiles and runs fine. t is non-static and it cannot be referenced in a static context in the main method. The variablet is not initialized and therefore causes errors. The variable x is not initialized and therefore causes errors.

  • Consider the following codes: public class TestThread extends Thread {     public static void main(String[] args)...

    Consider the following codes: public class TestThread extends Thread {     public static void main(String[] args) {         TestThread thread = new TestThread();     }     @Override     public void run() {         printMyName();     }     private void printMyName() {         System.out.println("Thread is running");     } } Test Stem / Question Choices 1: What method should you invoke to start the thread TestThread? A: start() B: run() C: No. Thread will run automatically when executed. D: TestThread is not...

  • Analyze the following code: public class Test { private int t; public static void main(String[] args)...

    Analyze the following code: public class Test { private int t; public static void main(String[] args) { int x; System.out.println(t); } } t is non-static and it cannot be referenced in a static context in the main method. The program compiles and runs fine. The variable t is not initialized and therefore causes errors. The variable x is not initialized and therefore causes errors.

  • 1. Look at the following pseudocode algorithm. package javaapplication292 public class JavaApplication292 ( public static void...

    1. Look at the following pseudocode algorithm. package javaapplication292 public class JavaApplication292 ( public static void main(StringlI args) recFun(258); public static void recFun( int x) if (x > 10) recFun (x/10); System.out. printIn( x % 10 ); else System.out.println(x); What is the output of the following statements? a. recFun(258); b. recFun (7);

  • This is for a java program public class Calculation {    public static void main(String[] args)...

    This is for a java program public class Calculation {    public static void main(String[] args) { int num; // the number to calculate the sum of squares double x; // the variable of height double v; // the variable of velocity double t; // the variable of time System.out.println("**************************"); System.out.println(" Task 1: Sum of Squares"); System.out.println("**************************"); //Step 1: Create a Scanner object    //Task 1. Write your code here //Print the prompt and ask the user to enter an...

  • import java.util.Scanner; public class StudentClient {       public static void main(String[] args)    {   ...

    import java.util.Scanner; public class StudentClient {       public static void main(String[] args)    {        Student s1 = new Student();         Student s2 = new Student("Smith", "123-45-6789", 3.2);         Student s3 = new Student("Jones", "987-65-4321", 3.7);         System.out.println("The name of student #1 is ");         System.out.println("The social security number of student #1 is " + s1.toString());         System.out.println("Student #2 is " + s2);         System.out.println("the name of student #3 is " + s3.getName());         System.out.println("The social security number...

  • X. (10 points) In the box provided show the output for this program segment public static...

    X. (10 points) In the box provided show the output for this program segment public static void main (String [) args) intl num-(1,2.3,4) System.out printinx+y+num12) tyit(y, x. num): System.out printin(x+ynum(2): public static void tryit(int a, int b, intl c) int x c[2]-20 System.out printin(x+bCI2) XI. (7 points) a. Write a method NEGATIVE that receives as parameters a one-dimensional array variable LIST of integers. The method should return the sum of the negative elements in the array. You may not assume...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT