java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.widget.RadioButton.getText()' on a null object reference
    final RadioGroup rg1=(RadioGroup)findViewById(R.id.Q1Group);
    final RadioGroup rg2=(RadioGroup)findViewById(R.id.Q2group);
    final RadioGroup rg3=(RadioGroup)findViewById(R.id.Q3Group);
    final RadioGroup rg4=(RadioGroup)findViewById(R.id.Q4Group);
    final RadioGroup rg5=(RadioGroup)findViewById(R.id.Q5Group);
    Button submitButton = (Button) findViewById(R.id.SubmitButton);
    submitButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            int score = 0;
            if (((RadioButton) findViewById(rg1.getCheckedRadioButtonId())).getText().equals(Integer.toString(q1num))) {
                score++;
            }
            if (((RadioButton) findViewById(rg2.getCheckedRadioButtonId())).getText().equals(Integer.toString(q2num))) {
                score++;
            }
            if(((RadioButton) findViewById(rg3.getCheckedRadioButtonId())).getText().equals(Integer.toString(q3num))){
                score++;
            }
            if(((RadioButton) findViewById(rg4.getCheckedRadioButtonId())).getText().equals(Integer.toString(q4num))){
                score++;
            }
            if(((RadioButton) findViewById(rg5.getCheckedRadioButtonId())).getText().equals(Integer.toString(q5num))){
                score++;
            }
            TextView scoreView = (TextView) findViewById(R.id.TotalScore);
            scoreView.setText(Integer.toString(score) + " / 5");
        }
    });
