AmbitionBox
Discover Best Places to work in India
Discover best places to work
Compare & find best workplace
Bring your workplace to life
Highlight your company's perks
Read reviews for 6L+ companies
Rate your former or current company
Discover salaries for 8L+ companies
Calculate your take home salary
Check your market value
Help other jobseekers
Read interviews for 90K+ companies
Interviews questions for 1K+ colleges
Contribute your interview questions
Java Programming
publicabstractclassAbstractTest {publicint getNum() { return45; } publicabstractclassBar {publicint getNum() { return38; } } publicstaticvoid main (String [] args) { AbstractTest t = new AbstractTest() { publicint getNum() { return22; } }; AbstractTest.Bar f = t.new Bar() { publicint getNum() { return57; } }; System.out.println(f.getNum() + " " + t.getNum()); } }what wll be the output?
publicabstractclassAbstractTest {publicint getNum() { return45; } publicabstractclassBar {publicint getNum() { return38; } } publicstaticvoid main (String [] args) { AbstractTest t = new AbstractTest() { publicint getNum() { return22; } }; AbstractTest.Bar f = t.new Bar() { publicint getNum() { return57; } }; System.out.println(f.getNum() + " " + t.getNum()); } }
57 22
45 38
45 57
An exception occurs at runtime.
publicclassHorseTest {publicstaticvoid main (String [] args) { classHorse {public String name; /* Line 7 */public Horse(String s) { name = s; } } /* class Horse ends */ Object obj = new Horse("Zippo"); /* Line 13 */ Horse h = (Horse) obj; /* Line 14 */ System.out.println(h.name); } } /* class HorseTest ends */what will be the output?
publicclassHorseTest {publicstaticvoid main (String [] args) { classHorse {public String name; /* Line 7 */public Horse(String s) { name = s; } } /* class Horse ends */ Object obj = new Horse("Zippo"); /* Line 13 */ Horse h = (Horse) obj; /* Line 14 */ System.out.println(h.name); } } /* class HorseTest ends */
An exception occurs at runtime at line 10
It prints "Zippo"
Compilation fails because of an error on line 7.
Compilation fails because of an error on line 13.
Which constructs an anonymous inner class instance?
Runnable r = new Runnable() { };
Runnable r = new Runnable(public void run() { });
Runnable r = new Runnable { public void run(){}};
System.out.println(new Runnable() {public void run() { }});
Which is true about a method-local inner class?
It must be marked final.
It must be marked abstract.
It must be marked public.
It must be marked static.
classBoo { Boo(String s) { } Boo() { } } classBarextendsBoo { Bar() { } Bar(String s) {super(s);} void zoo() { // insert code here } }which one create an anonymous inner class from within class Bar?
Boo f = new Boo(24) { };
Boo f = new Bar() { };
Bar f = new Boo(String s) { };
Boo f = new Boo.Bar(String s) { };
Join India’s largest community to research company culture
Are you a student or working professional?
Student/Never worked
I am a student/I have never worked
Working Professional
I am working/I have worked before
What are your preferred job locations?
Popular Cities
Other Cities
Follow your preferred designations/job profiles
Suggestions based on your job profile
vs
Similar Companies