The Artima Developer Community
Sponsored Link

Java Buzz Forum
Java Interview programming questions on this keyword

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
instanceof java

Posts: 576
Nickname: instanceof
Registered: Jan, 2015

instanceof java is a java related one.
Java Interview programming questions on this keyword Posted: Jul 6, 2016 10:01 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by instanceof java.
Original Post: Java Interview programming questions on this keyword
Feed Title: Instance Of Java
Feed URL: http://feeds.feedburner.com/blogspot/TXghwE
Feed Description: Instance of Java. A place where you can learn java in simple way each and every topic covered with many points and sample programs.
Latest Java Buzz Posts
Latest Java Buzz Posts by instanceof java
Latest Posts From Instance Of Java

Advertisement
  • Lets discuss some interesting programs on this keyword.
  • Now its time to practice some programs on this keyword. 
  • Try to guess the output of the following java programming questions on this keyword.
  • If you want explanations for all the programs please go through this keyword interview questions on java
Java Quiz on this keyword part #1



Program #1: Java interview programming question on this keyword.


  1. package thiskeywordinterviewprograms.java;
  2. public class ThisDemo {
  3.  
  4.     int a;
  5.     int b;
  6.     
  7. ThisDemo(int a, int b){
  8.  
  9.     a=a;
  10.     b=b;
  11.         
  12. }
  13.  
  14. public static void main(String[] args) {
  15.         
  16.     ThisDemo obj = new ThisDemo(10, 20);
  17.         
  18.      System.out.println(obj.a);
  19.      System.out.println(obj.b);

  20. }
  21.  
  22. }

Click for Output



Program #2: Java interview programming question on this keyword.

  1. package thiskeywordinterviewprograms.java;
  2. public class ThisDemo {
  3.  
  4.     int a;
  5.     int b;
  6.     
  7. ThisDemo(int a, int b){
  8.  
  9.     this.a=a;
  10.     this.b=b;
  11.         
  12. }
  13.  
  14. public static void main(String[] args) {
  15.         
  16.     ThisDemo obj = new ThisDemo(10, 20);
  17.         
  18.      System.out.println(obj.a);
  19.      System.out.println(obj.b);

  20. }
  21.  
  22. }

Click for Output


Program #3: Java Interview programming example on this keyword.

  • What will be the output of the below program

  1. package thiskeywordinterviewprograms.java;
  2. public class ThisDemo {
  3.  
  4.     int a;
  5.     int b;
  6.     
  7. ThisDemo(int a, int b){
  8.  
  9.     this.a=a;
  10.     this.b=b;
  11.         
  12. }
  13.  
  14. public static void main(String[] args) {
  15.         
  16.     ThisDemo obj = new ThisDemo();
  17.         
  18.      System.out.println(obj.a);
  19.      System.out.println(obj.b);

  20. }
  21.  
  22. }

Click for Output



Program #4: Java interview programming question on this keyword.


java programming examples on this keyword


Click for Output

  1. Zero argument constructor called.
  2. Two argument constructor called.
  3. x=1
  4. y=2

Read: Java Interview programming questions on this keyword

Topic: How to fix "variable might not have been initialized" error in Java Previous Topic   Next Topic Topic: 025: .NET and Beyond 12 Factors with Kevin Hoffman (Pivotal Conversations)

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use