Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MC question about programming (java language) Consider the following class: class Greeter { String name; public void sayHello() { System.out.println(Hello + name); } Select the

MC question about programming (java language)
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Consider the following class: class Greeter \{ String name; public void sayHello() \{ System.out.println("Hello" + name); \} Select the correct statement about generics in the following method declaration public static void foo( T a a. sayHello(); \} Select one: a. T can be instantiated with any class b. Tcan be instantiated with any subclass of Greeter c. the body of the method is incorrect, as T may not have a method Consider the following code public static void add(int a, int b) \{ return a+b; \} public static void add(String a, String b) \{ return a+b; \} This is an example of... Select one: a. Ad-hoc polymorphism b. Parametric polymorphism Marked out of 1.00 P Flag question Consider the following generic data type: class TreeNode { public T payload; public TreeNode left; public TreeNode right; public TreNode(T o) \{ payload = o; left = null; right = null; \} Is the following code correct? TreeNode> tree = new TreeNode (new Integer (4)); tree. left = new TreeNode> ("Five"); tree. right = new TreeNode> (new Integer (6)); Select one: a. no, because must be of type b. yes c. no, because must be of type Question 4 Not yet answered Marked out of 1.00 Flag question When is it preferable to use LinkedList vs ArrayList? When we need to perform many removal operations When we need to access elements at specific positions When we need to perform many insertion hich ones of the following for-each loops are allowed in Java? elect one or more: a. String[] strArray ={ "Hello", "world", "!" }; for (String s: strArray ){ I/ Get each element of strArray System.out.println(s); \} b. LinkedList intList =... If Creote list of integers for (Integer i: intList) { Get each element of intList System.out.println(i); \} c. String myStr = "Hello world!"; for (char c: mystr ) // Get each character of mystr System,out.println(c); \}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Principles Of Database Systems With Internet And Java Applications

Authors: Greg Riccardi

1st Edition

020161247X, 978-0201612479

More Books

Students also viewed these Databases questions

Question

a valuing of personal and psychological privacy;

Answered: 1 week ago