-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
43 lines (39 loc) · 988 Bytes
/
Copy pathMain.java
File metadata and controls
43 lines (39 loc) · 988 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.java;
//file name: Main.java
class Base {
protected void foo() {
System.out.println("Base.foo()");
}
}
class Derived extends Base {
protected void foo() {
System.out.println("Derived.foo()");
}
}
public class Main {
public static void gfg(String s)
{
System.out.println("String");
}
public static void gfg(Object o)
{
System.out.println("Object");
}
/*public static void gfg(Integer i)
{
System.out.println("Integer");
} */
public static void main(String args[]) {
Derived d = new Derived();
d.foo();
gfg(null);
String s1 = "abc";
String s2 = s1;
s1 += "d";
System.out.println(s1 + " " + s2 + " " + (s1 == s2));
StringBuffer sb1 = new StringBuffer("abc");
StringBuffer sb2 = sb1;
sb1.append("d");
System.out.println(sb1 + " " + sb2 + " " + (sb1 == sb2));
}
}