Subscribe To MegiSoft RSS Feeds!     Your Browser OR  Google Feedburner

Test Your Java Skill – Beginner Level

The beginners level (green level) offers simple and easy Java tests. Its level starts from a beginner programmers to programmers who have less than a year experience with Java.

If the tests are too difficult for you, then I would recommend to click the link under the Exercise title to read my article about that specific Java topic and try again.

Choose a level: Beginner  Intermediate  Advanced 

test-your-java-skill-beginner_480_324

Test 1: Easy constructors of subclasses and superclasses

Read More: Java Inheritance.

What happens when the following program is compiled and run?

class MySuper {

	protected int b;
}

final class MySub extends MySuper {

	int b = 5;

	MySub(int b) {
		System.out.print("-b" + super.b);
	}
	public static void main(String[] args){
		MySub mySub = new MySub(4);
	}
}

Select the correct answer.




Please, leave your questions, feedback and suggestions in the comments below! If you need more explanation by any of the answers, just let me know to update it for you!

Test 2: Local variables beginners level

Read More: Java Methods.
Read More: Java Classes And Objects.

What happens when the following program is compiled and run?

public class MyClass {

	int b = 4;

	public static void myMethod(int b){
		b ++ ;
		System.out.print("-b" + b);
		b ++ ;
	}
	public static void main(String args[]){
		int b = 2;
		myMethod(b);
	}
}

Select the correct answer.



Please, leave your questions, feedback and suggestions in the comments below! If you need more explanation by any of the answers, just let me know to update it for you!

Test 3: Simple inner classes beginners.

Read More: Java Nested And Inner Classes

What happens when you try to compile and run the following program?

class Outer {
	
	private int a = 12;
	
	class InnerA {
		int a = 4;
		public InnerA() {
			a -- ;
			System.out.print("-a" + a);
		}
		private void methodA(){
			a ++ ;
			System.out.print("-a" + a);
		}
	}
	public static void main(String[] args){
		InnerA innerA = new Outer().new InnerA();
	}
}

Select the correct answer.



Please, leave your questions, feedback and suggestions in the comments below! If you need more explanation by any of the answers, just let me know to update it for you!

Test 4: Array of an integer.

Read More: Java Arrays

What will happen if you try to compile and execute the main method?

public class MyArray {

	public static void main(String[] args){
		int[] arrayInt = new int[7];
		arrayInt[4] = 3;
		arrayInt[6] = 2;
		for(int i = 0; i < arrayInt.length; i ++ ) { if(i > 2) {
				System.out.print("-x" + arrayInt[i]);
			}
		}
	}
}

Select the correct answer.



Please, leave your questions, feedback and suggestions in the comments below! If you need more explanation by any of the answers, just let me know to update it for you!

Test 5: A simple Java method

Read More: Java Methods.
Read More: Java Constructors

What will happen if you try to compile and execute the main method?

public class MyMethod {

	double x = 12;
	double y = 10;

	public double getResult(double x, double y){
		return this.x + y;
	}
	public static void main(String[] args){
		MyMethod mm = new MyMethod();
		System.out.println(mm.getResult(4,3));
	}
}

Select the correct answer.



Please, leave your questions, feedback and suggestions in the comments below! If you need more explanation by any of the answers, just let me know to update it for you!

Megisoft.com offers a practical method to learn and improve your Java skills. It avoids unnecessary long boring theoretical explanations, but it uses many exercises and quizzes. The author of Megisoft is Sar Maroof who has more than a decade of experience with web development mainly with Java, MySql, HTML and more..
Choose a level: Beginner  Intermediate  Advanced 

Suggested Articles:


Click Here For Info about: Sar Maroof's New Java Book
Author: Sar Maroof
More than a decade of experience with developing web applications mainly with Java.
Sun Certified JSP as well as EJB
CIW Certified Internet Webmaster - Mind IT
Applied Science in Physics HBO Amsterdam
Bachellor Science in Physics at Basra university.
 Subscribe To Megisoft RSS Feeds! (Your Browser)
 Mail This Page To A Friend!
 Bookmark This Page!
Share on FacebookTweet about this on TwitterShare on RedditShare on LinkedIn

6 Comments

Add a Comment
  1. Hahaha I did better in the intermediate quiz than beginner. Confusion xD

  2. That’s really thinking at an imssrepive level

  3. In the first question, am I correct in saying that the answer, technically, is that main() prints nothing? Technically it is the MySub class object that has the print statement so it isn’t main() that prints anything? Obviously main() instantiates an object, MySub that does the printing? It is the MySub object that writes the answer.
    Great site!

    1. Thanks for your feedback!

      1. Wow, this is in every resepct what I needed to know.

    2. Action requires kngdelwoe, and now I can act!

Leave a Reply

megisoft © 2016