- Below programs are the basic programs frequently asking in java quizzes try to test your java programming skills by answering the questions. if you are having any doubts feel free to ask us.
- Java Coding Questions on constructors.
1.What will be the Output of this program.
- public class Test1{
- Test1(int i){
- System.out.println("Test1 Constructor "+i);
- }
- }
- public class Test2{
- Test1 t1= new Test1(10);
- Test2(int i){
- System.out.println("Test2 Constructor "+i);
- }
- public static void main(String[] args) {
- Test2 t2= new Test2(5);
- }
- }
2.What will be the Output of this program.
- public class A{
- A(){
- System.out.println("A Class Constructor ");
- }
- }
- public class B extends A{
- B(){
- System.out.println("B Class Constructor ");
- }
- public static void main(String[] args) {
- B ob= new B();
- }
- }
3.What will be the Output of this program.
- public class A{
- A(){
- this(0);
- System.out.println("Hi ");
- }
- A(int x){
- this(0,0);
- System.out.println("Hello");
- }
- A(int x, int y){
- System.out.println("How are you");
- }
- public static void main(String[] args) {
- A ob= new A();
- }
- }
superb explination i loved it
ReplyDeletegood
ReplyDeletethanks
ReplyDeletegood and thank you.
ReplyDeleteits very usefullllllllllllllllllllllllllllll
Thank You.
ReplyDeletethanks .. it will be useful for me
ReplyDelete