Question : What is the proper way to defined a method that take two int values and returns their sum as an int value?
1. int sum(int first, int second) { first + second; } 2. int sum(int first, second) { return first + second; } 3. Access Mostly Uused Products by 50000+ Subscribers 4. int sum(int first, int second) { return first + second; }
5. void sum (int first, int second) { return first + second; }
Correct Answer : Get Lastest Questions and Answer : Explanation: Java - String trim() Method This method returns a copy of the string, with leading and trailing whitespace omitted.
Question : You have been given following code
public class SampleClass { public static void main(String[] args) { AnotherSampleClass asc = new AnotherSampleClass(); SampleClass sc = new SampleClass(); sc = asc; System.out.println("sc: " + sc.getClass()); System.out.println("asc: " + asc.getClass()); } }
class AnotherSampleClass extends SampleClass { }
When you execute it, what will be printed ?
1. sc: class Object asc: class AnotherSampleClass 2. sc: class SampleClass asc: class AnotherSampleClass 3. Access Mostly Uused Products by 50000+ Subscribers 4. sc: class AnotherSampleClass asc: class AnotherSampleClass