Question

I need help with this please. Thank you.

11. A date or time conversion code within a format specifier is prefixed with a(n) 12. To call a static method from outside the class where it is defined, the method name must be prefixed with a(n) 13. A recursive method handles both and cases is the preferred method for creating threads in an application 15. Method explicitly calls the constructor of the parent class. a static method in the 16. A static method in a child class parent class with the same signature. is the top of the Java class hierarchy. 17. Class to connect a method call in Polymorphism in Java uses the parent class to the corresponding method in a child class. 18.

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

11. 't' or 'T'

Explanation: When writing a print statement for date or time conversion code within a format specifier, we write the character 't' or 'T' before the suffix character which is desired for specific time or date format. e.g.

import java.util.*;

public class Temp{

Date date = Calendar.getInstance().getTime();

System.out.printf("%tc", date);

System.out.printf("\n%Tc", date);

}}

whose output will be:

Wed Apr 25 15:11:34 UTC 2018
WED APR 25 15:11:34 UTC 2018

12. public

Explanation: when we define a static method in a class, we provide it with public access specifier to acces it from other class. e,g,

class Temp1{

public static void fun(){

System.out.println("Hello");

}

}

class Temp2{

public static void main(String[] args){

Temp1 obj = new Temp1();

obj.fun();

}

}

13. finite and infinite

Explanation: recursion is a tool used to convert loops to methods calling themselves which leads to infinte problems seeming as finite subproblems and calling itself. This also solves the problem of infinite loops.

14. start()

Explanation: threads are created by extending Thread class to your main class and defining the actual working of the thread in run method. But to actually run a thread, the object of Thread class is required to call start() method.

e.g.

class TempThread extends Thread {

public void run(){

// Execution of statements in the thread

}

public static void main(String [] args){

Thread t1 = new TempThread();

Thread t2 = new TempThread();

t1.start(); // calls run() method

t2.start(); // calls run() method

}

}

15. super()

e.g.

class A{

A(){

//construct of A defintion

}

}

class B extends A{

B(){

super() // calls constructor of A

// constructor definition of B

}

}

16. cannot override

Explanation: because static method is a class method which can be called by class name directly also from the reference variable(or object of class). During run time of the program, the definition of static method in parent class will be called, no overriding of method will be done.

17. Object class

Parent class of all classes in java

18. vitual method invocation

e.g.

class A{

public void fun1(){

// fun1 definition

}

}

class B extends A{

public void fun1(){

// fun1 definition

}

}

class Temp{

public static void main(String [] args){

B obj1 = new B();

A obj2 = new B(); // object creation with child class

obj1.fun1() // method from B class with be executed

obj2.fun1() // at the time of compilation, method from A class is checked but at run time, the method from B class is //executed

}

}

Add a comment
Know the answer?
Add Answer to:
I need help with this please. Thank you. 11. A date or time conversion code within...
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
  • PLEASE HELP this is the last part of my lab and I need help ): add comments please (: if it is to...

    PLEASE HELP this is the last part of my lab and I need help ): add comments please (: if it is too difficult you do not have to do part 3 but it would be greatly appreciated if you do ! Obtain example code files Circle.java, Shape.java, CircleShape2.java, Sphere.java, and CircleShapeApp.java from the downloaded files in Ch8. Compile and execute the example and understand the polymorphism it performs. (I have copied and pasted all of these files below) Modify...

  • Q1. Write a recursive function in C++ void printNumberedChars(string str, int i=0) { ... } which...

    Q1. Write a recursive function in C++ void printNumberedChars(string str, int i=0) { ... } which prints each character of the given string str on a new line, with each line numbered 1, 2, 3, …. For example calling the function with printNumberedChars("hello"); should output the following: 1. h 2. e 3. l 4. l 5. o Q2. Write a recursive function in C++ int sumArray(const int* arr, unsigned int size) { ... } which takes an array of integers,...

  • (1)     ____ is the principle that allows you to apply your knowledge of a general category...

    (1)     ____ is the principle that allows you to apply your knowledge of a general category to more specific objects.           a.       Inheritance              c.       Encapsulation           b.       Polymorphism                    d.       Override (2)     When you create a class by making it inherit from another class, you are provided with data fields and ____ automatically.           a.       fonts                      c.       class names           b.       methods                  d.       arrays (3)     By convention, a class diagram contains the ____ following each attribute or...

  • Please help me with my JAVA programming Exercise. a. The Talk-A-Lot Cell Phone Company provides phone...

    Please help me with my JAVA programming Exercise. a. The Talk-A-Lot Cell Phone Company provides phone services for its customers. Create an abstract class named PhoneCall that includes a String field for a phone number and a double field for the price of the call. Also include a constructor that requires a phone number parameter and that sets the price to 0.0. Include a set method for the price. Also include three abstract get methods—one that returns the phone number,...

  • I need the following written in Java please, thank you ' We want you to implement...

    I need the following written in Java please, thank you ' We want you to implement a java class that will show details on users and throw exceptions where needed. The following requirements specify what fields you are expected to implement in your User class: - A private String firstName that specifies the first name of the user - A private String lastName that specifies the last name of the user - A private int age that specifies user's age...

  • 1-Suppose you write an application in which one class contains code that keeps track of the...

    1-Suppose you write an application in which one class contains code that keeps track of the state of a board game, a separate class sets up a GUI to display the board, and a CSS is used to control the stylistic details of the GUI (for example, the color of the board.) This is an example of a.Duck Typing b.Separation of Concerns c.Functional Programming d.Polymorphism e.Enumerated Values 2-JUnit assertions should be designed so that they a.Fail (ie, are false) if...

  • Please explain each line of code, all code will be in Java. Thank you JKL Restaurant...

    Please explain each line of code, all code will be in Java. Thank you JKL Restaurant maintains a members’ club for its customers.  There are three levels of membership: (1) Basic, (2) Silver, and (3) Gold. A certain member has to be exactly a Basic, Silver, or Gold member at any point in time.  Whenever a member spends money at JKL, he/she gets points and as these points are accumulated, one can redeem one or more $20 dining certificates.  Each Gold member can...

  • Hello. I need help writing the following Java Program. Thank you Develop a class encapsulating the...

    Hello. I need help writing the following Java Program. Thank you Develop a class encapsulating the concept of a college course, assuming that a course has following attributers: code (for instance COSC1337), a description, and a number of credits (for instance 3). Include a constructor, the accessors, mutators and methods ‘toString’, ‘equals’, and ‘finalize’. Write a client class to test the behavior of the class and its methods. The outline of the class is given as follows: public class Course...

  • I NEED HELP with this. please create a UML diagram. I need a simple code to...

    I NEED HELP with this. please create a UML diagram. I need a simple code to solve the problem.   The ADT Bag is a group of items, much like what you might have with a bag of groceries. In a software development cycle, specification, design, implementation, test/debug, and documentation are typical activities. The details are provided in the rest of the document. ADT Bag Specification: (Note: You should not change the names of the operations in your program. This should...

  • Please show all work and answer all parts using python, thanks! Instructions You will need to...

    Please show all work and answer all parts using python, thanks! Instructions You will need to create four files: • Shape2D.py - file containing a class definition containing properties all Shapes could possibly have. • Circle.py - file containing a class definition of a Circle that inherits from the Shape2D class. Square.py - file containing a class definition of a Square that inherits from the Shape2D class. • testFile.py - file containing pytest functions testing the Shape2D, Circle, and Square...

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